SvelteKit "405 POST method not allowed" prerender in CI
A form submits a POST to a route, but the route has no actions to handle it. SvelteKit returns 405 with "No actions exist for this page", which can fail an end-to-end check or surface during prerendering of an action target.
What this error means
A POST to a route returns "405 ... POST method not allowed. No actions exist for this page" in a CI end-to-end run, or the build flags a prerendered page that receives a form submission.
Error: POST method not allowed. No actions exist for this page
Status: 405Common causes
A form posts to a page without actions
The +page.svelte has a method="POST" form but the matching +page.server.js exports no actions, so SvelteKit has nothing to run.
The form posts to the wrong route
The action attribute targets a path whose server module does not define the named action.
How to fix it
Define the action on the route
Export an actions object so the POST has a handler.
// src/routes/contact/+page.server.js
export const actions = {
default: async ({ request }) => {
const data = await request.formData();
return { success: true };
}
};Point the form at the route that has the action
Set the form action to the path whose server module defines it, including any named action.
<form method="POST" action="/contact?/default">How to prevent it
- Define
actionson every route a form posts to. - Match the form
actionpath to the route with the handler. - Cover form submission in an end-to-end test that runs in CI.