我试着用几个小时来配置我与码头的合并--我没有设法解决这个问题:
已被CORS策略阻止:请求的资源上没有“访问-控制-允许-原产地”标头。
我有这个文件
提取
mercure:
image : dunglas/mercure
volumes:
- ./mercure/caddy:/etc/caddy
ports:
- "8081:80"
- "443:443"
environment:
- SERVER_NAME=localhost
- MERCURE_SUBSCRIBER_JWT_KEY=changeIt
- MERCURE_PUBLISHER_JWT_KEY=changeIt
- MERCURE_CORS_ALLOWED_ORIGINS=*
- ALLOW_ANONYMOUS=1这个卡迪文件:
# The address of your server
localhost
:80
route {
mercure {
# Publisher JWT key
publisher_jwt changeIt
# Subscriber JWT key
subscriber_jwt changeIt
cors_origins http://localhost:3000
}
respond "Not Found" 404
}我在客户端的请求是有反应的
http.get('/api/mercure').then( response => {
this.setCookie( response.data.token);
const url = new URL('http://localhost:8081/.well-known/mercure');
url.searchParams.append('topic', 'http://agora.org/votes/{id}');
const eventSource = new EventSource(url, {withCredentials: true});
eventSource.onmessage = (data) => {
console.log(data);
}
},error => {
console.log( error);
})有人能帮我解决这件事吗?Thx预先
发布于 2021-02-14 17:38:17
我已经成功地使用了Mercure与docker-compose,没有CORS问题。您可以找到实现这里。
当我到达这里时,其他人也可能到达这里,也可能帮助那个人。
https://stackoverflow.com/questions/65361650
复制相似问题