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 working only in get method APIs #14

Closed
adibro500 opened this issue May 14, 2020 · 3 comments
Closed

CORS working only in get method APIs #14

adibro500 opened this issue May 14, 2020 · 3 comments

Comments

@adibro500
Copy link

CORS working only in get method APIs.

Even if i do: Access-Control-Allow-Origin in post requests, I still get CORS error.

Example:

Access to XMLHttpRequest at 'http://localhost:8000/api/edit/post' from origin 'http://localhost:4200' 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.

Thanks,
adibro500

@matt-42
Copy link
Owner

matt-42 commented May 14, 2020 via email

@adibro500
Copy link
Author

How to make it production ready then ?

@matt-42
Copy link
Owner

matt-42 commented May 14, 2020

You have 2 choices:
- setup the same gateway (nginx for example) that proxy your request to your static file server and to your api.
- serve your static files with lithium. See this example: https://github.com/matt-42/lithium/blob/master/libraries/http_backend/tests/serve_directory.cc#L25

@matt-42 matt-42 closed this as completed May 24, 2020
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

2 participants