Skip to content

Commit

Permalink
load from cdn if standaloneFilePath doesn't load
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Jan 6, 2025
1 parent 926e8ed commit bb5218e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/server/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as http from "node:http"
import * as fs from "node:fs"
import * as path from "node:path"
import { getNodeHandler } from "winterspec/adapters/node"
import pkg from "../../package.json"

// @ts-ignore
import winterspecBundle from "@tscircuit/file-server/dist/bundle.js"
import { getIndex } from "../site/getIndex"
Expand Down Expand Up @@ -30,10 +32,13 @@ export const createServer = async (port: number = 3000) => {
return
} catch (error) {
console.error("Error serving standalone.min.js:", error)
res.writeHead(404)
res.end("File not found")
return
}

res.writeHead(302, {
Location: `https://cdn.jsdelivr.net/npm/@tscircuit/runframe@${pkg.dependencies["@tscircuit/runframe"].replace(/^[^0-9]+/, "")}/dist/standalone.min.js`,
})
res.end()
return
}

if (url.pathname === "/") {
Expand Down

0 comments on commit bb5218e

Please sign in to comment.