Skip to content
Latchkey

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.

sveltekit
Error: POST method not allowed. No actions exist for this page
Status: 405

Common 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
// 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.

src/routes/contact/+page.svelte
<form method="POST" action="/contact?/default">

How to prevent it

  • Define actions on every route a form posts to.
  • Match the form action path to the route with the handler.
  • Cover form submission in an end-to-end test that runs in CI.

Frequently asked questions

What causes ""405 ... method not allowed""?
The +page.svelte has a method="POST" form but the matching +page.server.js exports no actions, so SvelteKit has nothing to run.
How do I fix "405 ... method not allowed"?
Export an actions object so the POST has a handler.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card