Skip to content

Commit f2a542c

Browse files
committed
fix: proxy Mercure through nginx at /hub to avoid CORS and match demo-enterprise pattern
1 parent e82bec4 commit f2a542c

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

.docker/nginx.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ server {
8686
deny all;
8787
}
8888

89+
# Proxy Mercure hub through nginx (same-origin, no CORS needed)
90+
location /hub {
91+
proxy_pass http://mercure/.well-known/mercure;
92+
}
93+
8994
# Some Admin Modules need this:
9095
# Server Info, Opcache
9196
location ~* ^/admin/external {

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ PIMCORE_OPENSEARCH_DSN=opensearch://admin:gBsVe!Dut723@opensearch:9200?ssl=true&
3333
PIMCORE_MESSENGER_TRANSPORT_DSN_PREFIX=amqp://guest:guest@rabbitmq:5672/%2f/
3434

3535
MERCURE_JWT_KEY=CHANGE_ME_THIS_IS_MY_SECRET_KEY_THAT_IS_LONG_ENOUGH_FOR_VALIDATION
36-
MERCURE_URL=http://localhost:8080/.well-known/mercure
36+
MERCURE_URL=http://localhost/hub
3737
MERCURE_SERVER_URL=http://mercure/.well-known/mercure

docker-compose.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ services:
7575
SERVER_NAME: ':80'
7676
MERCURE_PUBLISHER_JWT_KEY: 'CHANGE_ME_THIS_IS_MY_SECRET_KEY_THAT_IS_LONG_ENOUGH_FOR_VALIDATION'
7777
MERCURE_SUBSCRIBER_JWT_KEY: 'CHANGE_ME_THIS_IS_MY_SECRET_KEY_THAT_IS_LONG_ENOUGH_FOR_VALIDATION'
78-
MERCURE_EXTRA_DIRECTIVES: |-
79-
cors_origins http://localhost
80-
anonymous
78+
MERCURE_EXTRA_DIRECTIVES: anonymous
8179
# Uncomment the following line to enable the development mode
8280
# command: /usr/bin/caddy run -config /etc/caddy/Caddyfile.dev
8381
ports:

0 commit comments

Comments
 (0)