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

Bug: Redirect is not allowed for a preflight request. #3517

Open
2 of 4 tasks
BrianLYS opened this issue May 23, 2024 · 2 comments
Open
2 of 4 tasks

Bug: Redirect is not allowed for a preflight request. #3517

BrianLYS opened this issue May 23, 2024 · 2 comments
Labels
Bug 🐛 This is something that is not working as expected

Comments

@BrianLYS
Copy link

BrianLYS commented May 23, 2024

Description

Having issues with hosting the litestar application with a separate frontend.

Running pnpm run dev with litestar run -r works just fine.

Problem is getting this to production level infrastructure.

In my repository that I've linked, I place a caddy server infront of it and I end up receiving this error.

Access to fetch at 'http://localhost/accounts/login' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

URL to code causing the issue

https://github.com/BrianLYS/sveltekit-litestar-cors-error

MCVE

Access to fetch at 'http://localhost/accounts/login' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

Steps to reproduce

1. Start Caddy, Backend and Postgresql Server with `docker compose up` in root dir 
2. Start frontend server, `cd frontend/app`, `cp .env.example .env`, `pnpm install`, `pnpm run dev`
3. Open localhost:5173 in browser
4. Click register, fill in form.
5. Login with credentials.
6. Inspect console to see error log.

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

2.8.3

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@BrianLYS BrianLYS added the Bug 🐛 This is something that is not working as expected label May 23, 2024
@peterschutt
Copy link
Contributor

Are you interested in submitting a PR @BrianLYS?

@BrianLYS
Copy link
Author

@peterschutt a PR to include options method for litestar to pass redirects?
I tried to write a custom middleware previously to allow options but I couldn't solve it.

Seems this was brought up before too.
https://github.com/orgs/litestar-org/discussions/602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 This is something that is not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants