在 Windows 上使用 Symfony 运行 Mercure 时出错 - 本地/测试环境

问题描述

我正在尝试在本地环境(Windows 10)中使用 Mercure 和 Symfony 4 Framework。

尝试使用 symfony serve -d (https://localhost:8000/) 启动服务器 和 PHP -S localhost:3000 -t public 或 8000

使用 PowerShell 启动 Mercure Hub: $env:MERCURE_PUBLISHER_JWT_KEY='!ChangeMe!';$env:MERCURE_SUBSCRIBER_JWT_KEY='!ChangeMe!'; .\mercure.exe run -config Caddyfile.dev

访问 https://localhost/.well-kNown/mercure/ui/ => Mercure Hub 接口,好的

访问 https://localhost/.well-kNown/mercure: 缺少“topic”参数(不知道是否正常)

.env.local 文件(jwt 在 jwt.io !ChangeMe! 上创建)

MERCURE_PUBLISH_URL=https://localhost/.well-kNown/mercure
MERCURE_JWT_TOKEN=eyJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdLCJzdWJzY3JpYmUiOlsiKiJdfX0.Ws4gtnaPtM-R2-z9DnH-laFu5lDZrMnmyTpfU8uKyQo

index.html.twig

监听 HUB 的脚本。

url.searchParams.append('topic','https://example.com/my-private-topic'); 
const eventSource = new EventSource(url);
eventSource.onmessage = e => {
      console.log(e);
}

在此页面中,我还有一个按钮,用于调用调用 Mercure HUB 的控制器中的路由。

控制器(从 index.html.twig 访问的路由)

$update = new Update("https://example.com/my-private-topic","[]");
$publisher($update);

我在 Firefox 中的错误(在 Chrome 中相同):

Problem with the SSL CA cert (path? access rights?) for "https://localhost:8000/.well-kNown/mercure".

为什么会涉及到 8000 端口?我还没有在那个端口打开集线器。它设置为 localhost 简单。

Powershell 中的结果

2021/03/20 15:42:19.193 ←[34mINFO←[0m   http.log.access handled request {"request": {"remote_addr": "127.0.0.1:51637","proto": "HTTP/2.0","method": "GET","host": "localhost","uri": "/.well-kNown/mercure?topic=https%3A%2F%2Fexample.com%2Fmy-private-topic","headers": {"Accept-Language": ["fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"],"Accept-Encoding": ["gzip,deflate,br"],"Referer": ["https://127.0.0.1:8000/"],"Pragma": ["no-cache"],"User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0"],"Accept": ["text/event-stream"],"Origin": ["https://127.0.0.1:8000"],"Cache-Control": ["no-cache"],"Te": ["trailers"]},"tls": {"resumed": false,"version": 772,"cipher_suite": 4865,"proto": "h2","proto_mutual": true,"server_name": "localhost"}},"common_log": "127.0.0.1 - - [20/Mar/2021:16:42:19 +0100] \"GET /.well-kNown/mercure?topic=https%3A%2F%2Fexample.com%2Fmy-private-topic HTTP/2.0\" 200 2","duration": 1.4322458,"size": 2,"status": 200,"resp_headers": {"X-Xss-Protection": ["1; mode=block"],"Content-Security-Policy": ["default-src 'self' mercure.rocks cdn.jsdelivr.net"],"Expire": ["0"],"X-Content-Type-Options": ["nosniff"],"Access-Control-Allow-Origin": ["*"],"Cache-Control": ["private,no-cache,no-store,must-revalidate,max-age=0"],"x-frame-options": ["DENY"],"Connection": ["keep-alive"],"Content-Type": ["text/event-stream"],"X-Accel-Buffering": ["no"],"Alt-Svc": ["h3-32=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"],"Access-Control-Allow-Credentials": ["true"],"Server": ["Caddy"]}}  

感谢任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)