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

cors #13

Closed
dtdyq opened this issue Jul 22, 2023 · 2 comments
Closed

cors #13

dtdyq opened this issue Jul 22, 2023 · 2 comments

Comments

@dtdyq
Copy link

dtdyq commented Jul 22, 2023

Access to XMLHttpRequest at 'http://localhost:23486/main' from origin 'http://localhost:1420' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@metruzanca
Copy link

metruzanca commented Jul 28, 2023

I am also getting this. Heres my setup: https://github.com/metruzanca/quantframe

Access to XMLHttpRequest at 'http://localhost:17745/main' from origin 'http://localhost:1420' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Seems like every single run changes the port rust is using. How do we change it to be 1420 since thats the default the create-tauri-app uses?

@dominikbucher
Copy link

I think it suffices to change "http://localhost:8080" to "http://localhost:1420" when initially setting up the invoke handler.

The reason is that in https://github.com/tauri-apps/tauri-invoke-http/blob/dev/src/lib.rs#L17 the "Origin" of the request of the WebView is 1420, and it only gets admitted (meaning written back to "Access-Control-Allow-Origin") if it's in the originally specified whitelist.

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

No branches or pull requests

4 participants