Skip to content
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

Server actions forcing dynamic routes #52840

Closed
1 task done
ehwarren opened this issue Jul 18, 2023 · 3 comments · Fixed by #51534
Closed
1 task done

Server actions forcing dynamic routes #52840

ehwarren opened this issue Jul 18, 2023 · 3 comments · Fixed by #51534
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@ehwarren
Copy link

ehwarren commented Jul 18, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.6.7
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.10
      eslint-config-next: 13.4.9
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/bluegrv/next-js-server-actions-force-dynamic-route

To Reproduce

Building the app shows any route using a server action is forced to be dynamic
image

Describe the Bug

Whenever a server action is used in a component (server or client component) the corresponding route is forced to be dynamic.

There is an unanswered question in discord in regards to this: https://nextjs-forum.com/post/1118778071873486948

Expected Behavior

I would expect that the route should still be able to be static or SSG

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1453

@ehwarren ehwarren added the bug Issue was opened via the bug report template. label Jul 18, 2023
@shuding shuding self-assigned this Jul 19, 2023
@shuding shuding added the linear: next Confirmed issue that is tracked by the Next.js team. label Jul 19, 2023
@shuding
Copy link
Member

shuding commented Jul 19, 2023

This is on our roadmap, Server Actions should not affect the route itself.

@son1ss

This comment has been minimized.

@kodiakhq kodiakhq bot closed this as completed in #51534 Sep 14, 2023
kodiakhq bot pushed a commit that referenced this issue Sep 14, 2023
### 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
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants