{"record":{"id":"2b283be9814cc024","repo":"withastro/astro","slug":"url-pathname-colors-bold-method-requests-ar","errorCode":null,"errorMessage":"${url.pathname} ${colors.bold(method)} requests are not available in static endpoints. Mark this page as server-rendered (`export const prerender = false;`) or update your config to `output: 'server'` to make all your pages server-rendered by default.","messagePattern":"(.+?) (.+?) requests are not available in static endpoints\\. Mark this page as server-rendered \\(`export const prerender = false;`\\) or update your config to `output: 'server'` to make all your pages server-rendered by default\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/runtime/server/endpoint.ts","lineNumber":30,"sourceCode":"\tmod: {\n\t\t[method: string]: APIRoute;\n\t},\n\tcontext: APIContext,\n\tisPrerendered: boolean,\n\tlogger: AstroLogger,\n\tstate?: FetchState,\n) {\n\tconst { request, url } = context;\n\n\tconst method = request.method.toUpperCase();\n\t// use the exact match on `method`, fall back to ALL\n\tlet handler = mod[method] ?? mod['ALL'];\n\t// use GET handler for HEAD requests\n\tif (!handler && method === 'HEAD' && mod['GET']) {\n\t\thandler = mod['GET'];\n\t}\n\tif (isPrerendered && !['GET', 'HEAD'].includes(method)) {\n\t\tlogger.warn(\n\t\t\t'router',\n\t\t\t`${url.pathname} ${colors.bold(\n\t\t\t\tmethod,\n\t\t\t)} requests are not available in static endpoints. Mark this page as server-rendered (\\`export const prerender = false;\\`) or update your config to \\`output: 'server'\\` to make all your pages server-rendered by default.`,\n\t\t);\n\t}\n\tif (handler === undefined) {\n\t\tlogger.warn(\n\t\t\t'router',\n\t\t\t`No API Route handler exists for the method \"${method}\" for the route \"${url.pathname}\".\\n` +\n\t\t\t\t`Found handlers: ${Object.keys(mod)\n\t\t\t\t\t.map((exp) => JSON.stringify(exp))\n\t\t\t\t\t.join(', ')}\\n` +\n\t\t\t\t('all' in mod\n\t\t\t\t\t? `One of the exported handlers is \"all\" (lowercase), did you mean to export 'ALL'?\\n`\n\t\t\t\t\t: ''),\n\t\t);\n\t\t// No handler matching the verb found, so this should be a","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/runtime/server/endpoint.ts#L12-L48","documentation":"Astro endpoints render by matching the uppercase request method against exported handlers (GET, POST, ALL). When a route is prerendered to static files, only GET and HEAD can ever be served; the runtime checks isPrerendered && !['GET','HEAD'].includes(method) and logs this router warning telling you the route must be server-rendered for other verbs.","triggerScenarios":"A request with a method other than GET/HEAD (POST, PUT, DELETE, OPTIONS, ...) hitting an endpoint that has `export const prerender = true`, or any endpoint under output: 'static' — observable in the dev server, or whenever the static output is served behind something that forwards the request instead of rejecting it.","commonSituations":"A newsletter/contact POST handler on a mostly-static site; switching output: 'server' to 'static' and forgetting to flip one endpoint to prerender = false; testing endpoints with curl -X POST against a static build or the dev server.","solutions":["Add `export const prerender = false;` to the endpoint file so its handlers run on the server","Set output: 'server' in astro.config.mjs if most of the site should be dynamic","If the endpoint is meant to be static, restrict it to GET/HEAD and remove the other verb handlers"],"exampleFix":"// before  src/pages/api/subscribe.ts (project default is static)\nexport const POST: APIRoute = async ({ request }) => new Response('ok');\n\n// after\nexport const prerender = false;\nexport const POST: APIRoute = async ({ request }) => new Response('ok');","handlingStrategy":"validation","validationCode":"// Shared endpoint guard: reject writes deterministically when the route is prerendered\nexport const ALL: APIRoute = ({ request }) => {\n  if (import.meta.env.PRERENDER && !['GET', 'HEAD'].includes(request.method)) {\n    return new Response('Method Not Allowed', { status: 405 });\n  }\n  // ... dispatch by method\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit every non-GET handler for `export const prerender = false` before switching output modes","Write integration tests that POST to endpoints and assert they do not fall through to 404/405","Adopt a repo convention: any file under src/pages/api exporting POST/PUT/DELETE/PATCH must be server-rendered"],"tags":["astro","api-routes","endpoints","prerender","http-method"],"backgroundTag":"http-method-not-allowed","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}