0

I setup sawtooth-seth using this guide. After setting sawtooth-seth I tried to connect it with sawtooth-explorer. Both sawtooth-seth and sawtooth-explorer running successfully on docker. But sawtooth-explorer is not connecting with sawtooth-seth. I am getting the following cors policy blocked error.

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):  

Help me to fix this error.

Gurunath
  • 341
  • 3
  • 17

1 Answers1

0

You will get "Bad Gateway 502" error from Nginx in Docker container if you try to fetch transactions by sawtooth-explorer.

To solve your CORS problem to pass http proxy, you need to define port in your nginx.conf file to send the GET request to port of your nginx in Docker container.

For example if your Sawtooth rest-api is connected to port 8024, then you can configure sawtooth-explorer-rest-api-proxy to use also port 8024 in your nginx.conf file to pass http proxy.

Here's an extract from docker-compose.yaml file for rest-api

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

The sawtooth-explorer has relevant nginx configuration in docker folder.

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;
        }
    }