[GH-ISSUE #3410] [bug]: nginx, cors and axios errors #1142

Open
opened 2026-03-16 18:50:31 +03:00 by kerem · 3 comments
Owner

Originally created by @daemon-byte on GitHub (Oct 1, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3410

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I setup a basic hoppscotch on my server. I used nginx as a reverse proxy and subdomains for admin and backend. Hoppscotch opens and seems to work however the browser console is filled with errors and I can't register etc. The first issue I hit was no cors headers being set so I manually made them via nginx. However I am now getting a cors issue because the options request is getting a 405 from the graphql url. I'm at a loss now as to how to proceed as there's no errors in the docker compose logs and I can't find anything on backend. If anyone knows where I can look to track down some information on this that would be great.

Steps to reproduce

Setup the 3 images behind an nginx proxy.
Set the cors headers with nginx.
open the tool and check the browser console.

Environment

Production

Version

Self-hosted

Originally created by @daemon-byte on GitHub (Oct 1, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3410 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior I setup a basic hoppscotch on my server. I used nginx as a reverse proxy and subdomains for admin and backend. Hoppscotch opens and seems to work however the browser console is filled with errors and I can't register etc. The first issue I hit was no cors headers being set so I manually made them via nginx. However I am now getting a cors issue because the options request is getting a 405 from the graphql url. I'm at a loss now as to how to proceed as there's no errors in the docker compose logs and I can't find anything on backend. If anyone knows where I can look to track down some information on this that would be great. ### Steps to reproduce Setup the 3 images behind an nginx proxy. Set the cors headers with nginx. open the tool and check the browser console. ### Environment Production ### Version Self-hosted
Author
Owner

@daemon-byte commented on GitHub (Oct 1, 2023):

hopp

<!-- gh-comment-id:1742186326 --> @daemon-byte commented on GitHub (Oct 1, 2023): ![hopp](https://github.com/hoppscotch/hoppscotch/assets/517787/b60358bd-2edc-4a0e-9d4d-e0274e307aac)
Author
Owner

@owlpro commented on GitHub (Oct 8, 2023):

@daemon-byte hi check out this config for backend proxy pass

server {
    server_name back.domain.com;

    # HTTP configuration
    listen 80;

    # HTTP to HTTPS
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    }

    # HTTPS configuration
    listen 443 ssl; # managed by Certbot
    ssl_certificate  /path/to/cert # managed by Certbot
    ssl_certificate_key /path/to/cert # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    location / {
        proxy_pass  http://localhost:3170;
        proxy_redirect                      off;
        proxy_set_header  Host              $http_host;
        proxy_set_header  X-Real-IP         $remote_addr;
        proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_read_timeout                  86400;
        proxy_set_header 		    Upgrade $http_upgrade;
        proxy_set_header 		    Connection "upgrade";
    }
}
<!-- gh-comment-id:1751986902 --> @owlpro commented on GitHub (Oct 8, 2023): @daemon-byte hi check out this config for backend proxy pass ``` server { server_name back.domain.com; # HTTP configuration listen 80; # HTTP to HTTPS if ($scheme != "https") { return 301 https://$host$request_uri; } # HTTPS configuration listen 443 ssl; # managed by Certbot ssl_certificate /path/to/cert # managed by Certbot ssl_certificate_key /path/to/cert # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot location / { proxy_pass http://localhost:3170; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 86400; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } ```
Author
Owner

@daemon-byte commented on GitHub (Oct 9, 2023):

@daemon-byte hi check out this config for backend proxy pass

Thanks for that but it didn't alter anything. I think for some reason it might be ignoring my env file. I noticed this in the logs which is surely wrong? Those origins were not in the env file.

  hoppscotch_admin:
    image: hoppscotch/hoppscotch-admin:latest
    ports:
      - '10009:8080'
    restart: unless-stopped
    container_name: hoppscotch-admin
    env_file:
      - ./stack.env
    depends_on:
      - postgres

WHITELISTED_ORIGINS=http://localhost:8009,http://localhost:9009,http://localhost:10009
hoppscotch-admin    | {"level":"info","ts":1696877247.30753,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
hoppscotch-admin    | {"level":"warn","ts":1696877247.3093703,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
hoppscotch-admin    | {"level":"info","ts":1696877247.3137343,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
hoppscotch-admin    | {"level":"info","ts":1696877247.315344,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x40003d8100"}
<!-- gh-comment-id:1753503056 --> @daemon-byte commented on GitHub (Oct 9, 2023): > @daemon-byte hi check out this config for backend proxy pass > Thanks for that but it didn't alter anything. I think for some reason it might be ignoring my env file. I noticed this in the logs which is surely wrong? Those origins were not in the env file. ``` hoppscotch_admin: image: hoppscotch/hoppscotch-admin:latest ports: - '10009:8080' restart: unless-stopped container_name: hoppscotch-admin env_file: - ./stack.env depends_on: - postgres ``` ``` WHITELISTED_ORIGINS=http://localhost:8009,http://localhost:9009,http://localhost:10009 ``` ``` hoppscotch-admin | {"level":"info","ts":1696877247.30753,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"} hoppscotch-admin | {"level":"warn","ts":1696877247.3093703,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2} hoppscotch-admin | {"level":"info","ts":1696877247.3137343,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]} hoppscotch-admin | {"level":"info","ts":1696877247.315344,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x40003d8100"} ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1142
No description provided.