-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰 Bug]: Calling server actions on a static or SSR pages returns 405: Method Not Allowed #679
Comments
Please can you try passing your server action from a server component to a child component as a prop, as a workaround? |
I updated the reproduction repo so It works fine in dev and with |
I ran into the same issue. For now, I just moved from Cloudflare Pages to Vercel and that fixed it. I would love to move back when/if this gets resolved. I'm not a very good frontend developer, so I wanted to follow along with the latest Next.js docs / online content. |
Same issue here |
Yeah, I got same 405 on POST forms for Next-Auth V5beta (edge ready) or Iron-session v8 (edge ready). |
any updates on this? :/ |
I haven't investigated it because I've been pretty busy, but my assuption would be if you're calling it from a prerendered/non-edge route, i would speculate that on Vercel they bypass the prerendered route and invoke the nodejs fallback function for action calls on static routes, which is not something we are able to do. It's a theory that would make sense - how would you be able to call a server action if there is no function for it to invoke at that route? So, I would imagine that route's would need to use the edge runtime to call a server action, so that there is actually a function that it can run for your action call. |
For those coming from google. The "workaround" is to just make sure all pages are using edge with this line in your export const runtime = 'edge'; |
This is not good as the page counted as an edge function then you all pay for it like a worker request, which is not fairplay for web pages. |
You pay for a worker request on requests to all routes with next-on-pages, because all requests to your routes go through our routing system in order to be correctly matched up to the page (whether prerendered or SSR'd). I'm not sure I follow how you'd expect a server action to work when there's no edge function for the action to invoke? |
next-on-pages environment related information
Description
Next allows server actions on static, SSR and edge routes.
next-on-pages, however, doesn't seem to register POST routes if the page isn't using the edge runtime, causing them to return 405s.
Reproduction
Repo: https://github.com/Maronato/next-on-pages-server-actions-repro
The files changed in the repo are
src/action.ts
andsrc/app/hello/page.tsx
Repo setup
npm install
Desired behavior
npm run dev
(alternatively,npm run build
,npm run start
)Pages behavior
npm run preview
Pages Deployment Method
None
Pages Deployment ID
No response
Additional Information
No response
Would you like to help?
The text was updated successfully, but these errors were encountered: