Skip to content

Commit

Permalink
Add CORS and browser issue hint (fixes #56) (#58)
Browse files Browse the repository at this point in the history
* Add CORS and browser issue hint (fixes #56)

Hey,

I've added some hints on browser issues to the trouble section and also changed the default parameters for the binary example.

Cheers
Matthias

* Update README.md
  • Loading branch information
althaus authored and dunglas committed Mar 11, 2019
1 parent f35c47c commit a1d2496
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ A managed, high-scalability version of Mercure is available in private beta.

Grab a binary from the release page and run:

JWT_KEY='myJWTKey' ADDR=':3000' DEMO=1 ALLOW_ANONYMOUS=1 PUBLISH_ALLOWED_ORIGINS='http://localhost:3000' ./mercure
JWT_KEY='myJWTKey' ADDR=':3000' DEMO=1 ALLOW_ANONYMOUS=1 CORS_ALLOWED_ORIGIN=* PUBLISH_ALLOWED_ORIGINS='http://localhost:3000' ./mercure

The server is now available on `http://localhost:3000`, with the demo mode enabled. Because `ALLOW_ANONYMOUS` is set to `1`, anonymous subscribers are allowed.

Expand Down Expand Up @@ -239,6 +239,10 @@ If not, an HTTP server will be started (**not secure**).

For both the `publish` and `subscribe` properties, the array can be empty to publish only public updates, or set it to `["*"]` to allow accessing to all targets.

#### Browser Issues

If subscribing to the `EventSource` in the browser doesn't work (the browser instantly disconnects from the stream or complains about CORS policy on receiving an event), check that you've set a proper value for `CORS_ALLOWED_ORIGINS` on running Mercure. It's fine to use `CORS_ALLOWED_ORIGINS=*` for your local development.

#### URI Template and Topics

Try [our URI template tester](https://uri-template-tester.mercure.rocks/) to ensure that the template matches the topic.
Expand Down

0 comments on commit a1d2496

Please sign in to comment.