-
Notifications
You must be signed in to change notification settings - Fork 27k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEXT-1167] Server Actions 405 "Method Not Allowed" when using generateStaticParams #49408
Comments
Hi, can confirm just had the same bug. |
Same thing here, the moment I removed generateStaticParams, it worked |
This comment was marked as spam.
This comment was marked as spam.
any updates on this issue? |
Also had the same issue with 405 http errors and errors in the console... Commenting the generateStaticParams function fixes. When are you expecting to publish the fix ? |
Same for me! Trying to use server actions gave me 405 all the time. Removing generateStaticParams made the server actions work...but...yea.. I need generateStaticParams too! :) |
I'm not using My server action takes files as form data and uploads those files to google cloud. |
@Tommoore96 Would you be able to get a minimal reproduction? Your situation might need to be a separate github issue. |
Same here I'm not using generateStaticParams but still get 405 errors, I am not able to use my api files somehow! Work perfectly in local |
Same here. When I removed generateStaticParams, it worked. |
Trying to do internationalization, and in my end the same problem. I am using generateStaticParams in the root layout, then server actions in all my routes get 405 method not allowed. Removing generateStaticParams make it works, but it is not a fix as i need this for locales. This is related to : #49373 (comment) |
Facing the same issue when using server actions along with getStaticParams. |
Bump Is there anybody from Next on this issue? Happy to look into into it. |
Do we know if this is a bug or can we not use server actions with generateStaticParams pages? |
This error occurs in development only. Try building the app then running it in production, it will work just fine. |
405 error in production on [POST] from Vercel logs. Page renders static content correctly then errors on Server action POST... |
Behaviour is still present on |
Error happens in production too, just not printing anything in server console (browser console and network tab still show 405) |
Did anyone manage to find a workaround for this? |
I was adding i18n support to my website following this guide and ran into this issue as well. In my case, I was getting failures with server actions when my layout file was in my Splitting out the layout files into two, one at the app route ( |
Also, I have the same issue. I am removing the generateStaticParams function, and the server action works property. Why can't we use both generateStaticParams and server actions? |
This comment has been minimized.
This comment has been minimized.
Same issue here. with generateStaticParams
@AndrewRPorter were you using generateStaticParams? I'm using i18n too. could you please provide an example of how you split your layouts? |
any other way to solve it ??? i have the same issue after adding app/[lang] |
same here i just tried it and it works for me too |
Didn't find this issue at first because it doesn't include the error message I am getting. In case anyone else gets the same error message, here it is:
|
We are talking about it in the next-intl repo as well: amannn/next-intl#353 I think next.js should look into this if they plan to release server actions as beta or stable soon |
### What? Pages marked with `generateStaticParams` don't currently support server actions, and instead return a 405 Method Not Allowed, with no action being taken on the client. Additionally, pages that are marked static & use server actions are opted into dynamic rendering. ### Why? The page that has `generateStaticParams` is marked as `isSSG` [here](https://github.com/ztanner/next.js/blob/ee2ec3dd1de2f5cdd26ddc64c1036f02c92e1888/packages/next/src/server/base-server.ts#L1337). As a result, the request is short-circuited because a POST request isn't supported on static pages. Upon detecting a server action on a page marked SSG, we bypass the static cache and go straight to the lambda. This PR introduces an experimental option to the prerender manifest that will allow for selectively bypassing the static cache This also removes the need to bail out of static generation Closes NEXT-1167 Closes NEXT-1453 Fixes #49408 Fixes #52840 Fixes #50932
OMG 😱 Thank you! Amazing work |
I found a workaround You can currently bypass the error by turning your page from
Made a YT video as well: https://youtu.be/K6Jn24FsZFc |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Wed, 26 Apr 2023 20:50:14 +0000 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 13.4.1 eslint-config-next: 13.0.6-canary.1 react: 18.2.0 react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No responseServer actions. It seems like server actions wasn't part of the issue form dropdown earlier
Link to the code that reproduces this issue
https://github.com/arduano/server-actions-repro
To Reproduce
npm install
npm run dev
/asdf
in the browserDescribe the Bug
Including
generateStaticParams
in a page breaks server actions, making it return 405 on each requestExpected Behavior
The server actions behave as expected
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1167
The text was updated successfully, but these errors were encountered: