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

Cross-site POST form submissions are forbidden #12851

Closed
1 task
wildfiremedia opened this issue Dec 29, 2024 · 3 comments
Closed
1 task

Cross-site POST form submissions are forbidden #12851

wildfiremedia opened this issue Dec 29, 2024 · 3 comments
Labels
needs triage Issue needs to be triaged

Comments

@wildfiremedia
Copy link

Astro Info

Astro                    v5.1.1
Node                     v22.12.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

In transition from 4.x to 5.x, I found I could not submit the form when testing in npx astro preview after the build, on macOS. Is it something we need to disable CORS?

Submit a form to the same origin threw Cross-site POST form submissions are forbidden which is weird.

What's the expected result?

Tested on localhost:8080 should continue to work as expected in 5.x?

Link to Minimal Reproducible Example

NA

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 29, 2024
@Lippiece
Copy link

Lippiece commented Dec 29, 2024

This is really painful. I needed a quick MVP and can't deploy it on Render because the app refuses to perform POST requests to itself.

All I found is the exact same message in Svelte Kit. How can we disable this behaviour here? Setting ORIGIN env doesn't seem to have any effect.

@wildfiremedia
Copy link
Author

wildfiremedia commented Dec 30, 2024

Just discovered I need to disable this check when running preview

Nginx port localhost:8080
Astro on port localhost:3232
Web browser: localhost:8080

Mentioned in the docs, CSRF protection is enable by default for 5.x.

asstro.config.mjs

security: {
    checkOrigin: false
  }

@wildfiremedia
Copy link
Author

@Lippiece Worth reading :)
https://docs.astro.build/en/reference/configuration-reference/#security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants