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 policy: No 'Access-Control-Allow-Origin' header is present on the requested resource #911

Open
vitamin-code opened this issue May 31, 2024 · 2 comments

Comments

@vitamin-code
Copy link

Hello,

I finally installed the mercure hub on a virtual machine. My publish is working but when I'm trying to subscribe, then I get the CORS error. I'm running the mercure hub docker image inside the ubuntu VM and within that VM, I have nginx that listens to that port 8080.

Here's my nginx
image

Here's my docker run command:

docker run -d -e SERVER_NAME=':80' 
-e MERCURE_PUBLISHER_JWT_KEY='MY_MERCURE_JWT_KEY' 
-e MERCURE_SUBSCRIBER_JWT_KEY='MY_MERCURE_JWT_KEY' 
-e MERCURE_EXTRA_DIRECTIVES="cors_origins https://localhost:8000" 
-p 8080:80 dunglus/mercure

Still, I get the CORS error on my local

@vitamin-code vitamin-code changed the title CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource even for Anonymous CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource May 31, 2024
@dunglas
Copy link
Owner

dunglas commented May 31, 2024

For Caddy to read the host forwarded by NGINX, you have to the trusted_proxies global option: https://caddyserver.com/docs/caddyfile/options#trusted-proxies

Could you check if it fixes your issue?

@vitamin-code
Copy link
Author

Hi @dunglas , I don't know where to find the Caddy file since I'm running inside the virtual machine a docker to run the mercure container

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