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

Add CORS headers to server #749

Closed
Martijnpold opened this issue Apr 10, 2020 · 5 comments
Closed

Add CORS headers to server #749

Martijnpold opened this issue Apr 10, 2020 · 5 comments

Comments

@Martijnpold
Copy link

Currently our Angular based project is failing to connect to our java socket-io backend. As far as we can see this happens due to the browser rejecting the connection because of an invalid CORS header.

How do you configure these headers to be correct and allow any connection from any IP?

We tried:
config.setOrigin("");
config.setOrigin("[full ip]");
config.setOrigin("[full ip]:
");
and various mutations similar, none seem to work though

@pim97
Copy link

pim97 commented Apr 18, 2020

Could you try this

config.setOrigin("*");

It adds a wildcard to the 'Access-Control-Allow-Origin' header

@voonic
Copy link

voonic commented Aug 16, 2022

Could you try this

config.setOrigin("*");

It adds a wildcard to the 'Access-Control-Allow-Origin' header

does not work

@BenanaH
Copy link

BenanaH commented Feb 14, 2023

I have a same probelem.Is there something way to solve this?

@yujuncai
Copy link

config.setAllowHeaders("*");

@Martijnpold
Copy link
Author

Old post but I believe this can also be solved by using the angular proxy configuration (partially an assumption, but I've had similar things with rest api's in dev environments).

More here: https://angular.io/guide/build#proxying-to-a-backend-server

Will close this issue and good luck to anyone reading this.

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

5 participants