Is this possible to get mercure protocol with Heroku using API platform?

Viewed 914

I deployed a API Platform api and client using Heroku but it seems that Mercure is not working out of the box, but I think my application may have missing configuration.

The only thing I configured is this MERCURE_SUBSCRIBE_URL=http://my-random-herokuapp-name-generated.herokuapp.com/hub.

In production I'm getting 404 error on my hub address and in local I get an answer saying I didn't provide a topic (which makes sense because I just requested the address to make a test without providing any parameter).

In local environment, the full package API platform is given with a docker running a mercure server, I think this might be the answer that herokuapp doesn't support Mercure, but it's not very clear to me.

So basically I am getting a 404 not found error on the hub address instead of getting a 200

2 Answers

To use Mercure with API Platform, you have to also deploy a Mercure hub. The hub can be downloaded on https://mercure.rocks. Then you can deploy it easily on Heroku as a Go application.

Your Procfile should look like:

web: ADDR=$PORT ./mercure

To everyone, even if unsecure (look at mercure doc to know more https://mercure.rocks/docs/hub/install)

this Procfile just work out of the box with heroku

web: ADDR=:$PORT ./mercure --jwt-key='!ChangeMe!' --debug --allow-anonymous --cors-allowed-origins='*' --publish-allowed-origins='*'
Related