我使用this guide设置了sawtooth seth。在设置sawtooth seth之后,我尝试将其连接到sawtooth-explorer。sawtooth seth和sawtooth explorer都在docker上成功运行。但是sawtooth explorer和sawtooth seth没有连接。我收到以下cors策略阻止错误。
Access to XMLHttpRequest at 'http://localhost:8080/transactions?limit=10' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
explorer.component.ts:210 Error fetching items from API (transactions): 帮我修复这个错误。
发布于 2020-03-11 13:29:49
如果您尝试通过sawtooth explorer获取事务,您将在Docker容器中收到来自Nginx的"Bad Gateway 502“错误。
为了解决您的CORS问题传递http proxy,您需要在您的nginx.conf文件中定义端口,将GET请求发送到您的nginx在Docker容器中的端口。
例如,如果您的锯齿rest-api连接到端口8024,那么您可以配置Sawtooth explorer-rest-api- proxy,以便在您的nginx.conf文件中使用端口8024来传递http代理。
以下是rest-api的docker-compose.yaml文件的摘录
docker-compose.yaml
rest-api:
image: hyperledger/sawtooth-rest-api:1.0
container_name: supply-rest-api
expose:
- 8008
ports:
- '8024:8008'
depends_on:
- validator
entrypoint: |
sawtooth-rest-api -vv
--connect tcp://validator:4004
--bind rest-api:8008锯齿资源管理器在docker文件夹中有相关的nginx配置。
nginx.conf
server {
listen 8090;
add_header Pragma no-cache always;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, OPTIONS';
add_header Access-Control-Allow-Headers 'X-XSRF-TOKEN,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
location / {
#proxy_pass http://localhost:8008;
proxy_pass http://192.168.3.10:8024;
proxy_read_timeout 5000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}https://stackoverflow.com/questions/59797442
复制相似问题