mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
Merge 0518bfcdf7 into 355d1e79d9
This commit is contained in:
commit
7901a6853a
2 changed files with 10 additions and 5 deletions
|
|
@ -45,6 +45,9 @@ const pages: {
|
|||
{ path: "/check-worker-start-404", status: 404, static: true },
|
||||
{ path: "/ja/check-worker-start-404", status: 404, static: true },
|
||||
{ path: "/devices", status: 404, static: true },
|
||||
{ path: "/_server?id=337aeb1a-9f11eae1", status: 410 },
|
||||
{ path: "/_server", status: 410 },
|
||||
{ path: "/_server/subscription.get", status: 410 },
|
||||
{ path: "/docs/", status: 200 },
|
||||
{ path: "/docs/config/", status: 200, accept: "text/markdown" },
|
||||
{ path: "/v2/docs/config/", status: 301, location: "/docs/config/" },
|
||||
|
|
|
|||
|
|
@ -33,13 +33,10 @@ const pages = fileRoutes as {
|
|||
[handler: string]: unknown
|
||||
}[]
|
||||
|
||||
/** Whether an API route or a server function (SolidStart's /_server) answers a request, not a page. A HEAD
|
||||
* request is answered by the route's GET handler. */
|
||||
/** Whether an API route answers a request, not a page. A HEAD request is answered by the route's GET handler. */
|
||||
const answered = (path: string, method: string) =>
|
||||
path.startsWith("/_server") ||
|
||||
pages.some(
|
||||
(route) =>
|
||||
!route.page && (route[`$${method}`] || (method === "HEAD" && route.$GET)) && matches(route.path, path),
|
||||
(route) => !route.page && (route[`$${method}`] || (method === "HEAD" && route.$GET)) && matches(route.path, path),
|
||||
)
|
||||
|
||||
/** The methods an address takes: an API route's handlers (HEAD with GET), else a page's GET and HEAD. */
|
||||
|
|
@ -64,6 +61,11 @@ export const staticPages: Middleware = async (_event, next) => {
|
|||
if (import.meta.env.DEV || !event) return next()
|
||||
const url = new URL(event.request.url)
|
||||
const path = strip(url.pathname)
|
||||
// Production hydrates no page and ships no app JavaScript, so nothing calls SolidStart's /_server
|
||||
// endpoint anymore. Answer stale tabs and probes with 410 instead of letting SolidStart throw 500
|
||||
// on retired function ids (matching the Cloudflare WAF rule for legacy 64-hex ids).
|
||||
if (path === "/_server" || path.startsWith("/_server/"))
|
||||
return new Response(null, { status: 410, headers: { "Cache-Control": "private, no-store" } })
|
||||
// Pages only answer GET and HEAD. A method nothing handles gets a 405 listing the methods the address takes,
|
||||
// not the app's document, whose scripts production no longer ships.
|
||||
if (event.request.method !== "GET" && event.request.method !== "HEAD")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue