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

Allowed origins #79

Open
ShulV opened this issue Feb 4, 2024 · 3 comments
Open

Allowed origins #79

ShulV opened this issue Feb 4, 2024 · 3 comments

Comments

@ShulV
Copy link

ShulV commented Feb 4, 2024

Didn't work for me without additional permission.
I launched the front using "Live Server" in VS Code on 5500 port.
I had to add the line .setAllowedOrigins("http://127.0.0.1:5500/") to make it work.

@Override
	public void registerStompEndpoints(StompEndpointRegistry registry) {
		registry.addEndpoint("/gs-guide-websocket")
				.setAllowedOrigins("http://127.0.0.1:5500/");//I added it
	}
@wangzzleo
Copy link

Didn't work for me without additional permission. I launched the front using "Live Server" in VS Code on 5500 port. I had to add the line .setAllowedOrigins("http://127.0.0.1:5500/") to make it work.

@Override
	public void registerStompEndpoints(StompEndpointRegistry registry) {
		registry.addEndpoint("/gs-guide-websocket")
				.setAllowedOrigins("http://127.0.0.1:5500/");//I added it
	}

.setAllowedOrigins("*")

@robertmcnees
Copy link
Contributor

Hi @wangzzleo and @pksilen from #82. Thanks for the issue.

I just ran through the guide and it works as is for me without needing the .setAllowedOrigins() code.

How are you launching the application? Are you using your IDE? When I tested it successfully I executed the ./gradlew bootRun command from the complete directory.

@cyberpunkoff
Copy link

@robertmcnees, hi!

I just ran into that issue myself. There is no problem with the project itself. In the guide on the site clearly stated that you should visit localhost:8080 to interact with the app, but if you access it through 127.0.0.1:8080 ui renders just fine as well. But when you try to connect to the websocket, connection fails due to CORS policy.

You have to access the site through localhost as specified in the guide or add allowed origin. It might not be a bug, but I think it needs to be mentioned somewhere, because there is no messages in spring's logs (at least in default log configuration) and it's quite tricky to understand whats the problem.

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

No branches or pull requests

4 participants