I got a problem with configure mercure under symfony with vue. I'm using mercure hub which is attached in symfony cli. in .env file I changed mercure urls to using http because it caused me error with certificate(which was included by symfony).
.env
MERCURE_URL=http://localhost:8000/.well-known/mercure
MERCURE_PUBLIC_URL=http://localhost:8000/.well-known/mercure
MERCURE_JWT_SECRET="!ChangeMe!"
When I test it by opening symfony app in example http://localhost:8000 and adding this script in console:
const eventSource = new EventSource('http://localhost:8000/.well-known/mercure?topic=' + encodeURIComponent('http://example.com/books/1'));
eventSource.onmessage = event => {
// Will be called every time an update is published by the server
console.log(JSON.parse(event.data));
}
It is working and I can publish some changes in other tab. BUT when I do the same but in my vue app which is located on http://localhost:8080 address it shows me in console error:
Access to resource at 'http://localhost:8000/.well-known/mercure?topic=http://example.com/books/1' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Also I got 2 more questions:
- Why when I paste jwt token in env I got 401 errors but with this one above not?
- Why I cant use symfony serve with https? I got errors with "TransportException: fopen(): Unable to locate certificate CN"