mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 09:16:03 +03:00
[GH-ISSUE #3118] [bug]: whitelisted_origins for CORS being ignored for proxied URLs for /graphql endpoint #1026
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1026
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @conall88 on GitHub (Jun 6, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3118
Is there an existing issue for this?
Current behavior
When running the backend app with CORS set to production settings, the /graphql endpoint will return HTTP 521 "CORS Missing Allow Origin" even when the relevant path is specified in .env, in cases where a reverse proxy is present.

I'm trying to set this up using the docker compose method.
below are the relevent conf snippets:
.ENV
frontend config:
I've attached a .HAR file incl the response here: har file.zip
Other endpoints seem to work fine so far, and similar cloudflare proxy configuration is working fine for other applications / kubernetes containers.
Port 2087 may be used for HTTPS workloads with cloudflare, and i've set the proxy to flexible encryption, meaning encryption between the cloudflare loadbalancer and the browser only.
Let me know if there is a debug log I can enable to narrow down the issue further. I didn't see anything via info/warn level logs Thanks.
Steps to reproduce
set port 2096 for the hoppscotch-sh-admin container in .env
docker compose build
docker compose up -d
expose the hoppscotch-sh-admin container behind a reverse proxy which proxies requests from
http://localhost:2096tohttps://<somehost>:2096open https://somehost:2096 in a browser.
see the POST and OPTIONS to /graphql at
https://<somehost>:2087fail.Environment
Production
Version
Self-hosted
@conall88 commented on GitHub (Jun 12, 2023):
I just noticed this behaviour affects the default configuration example, and i've been looking for a first issue in an OSS project, so I hope this is welcome:
I see this CORS handling is being done by nestJS as per:
https://docs.nestjs.com/security/cors
First theory is that the the NodeJS env vars aren't being read properly via process.env..split
I've therefore set :
and set
in .env to test after doing a build.
outcome:
CORS directives are respected and functional:
so it looks like
github.com/hoppscotch/hoppscotch@e3dd9e99a1/packages/hoppscotch-backend/src/main.ts (LL32)is the culprit.I haven't been able to solve, but did add some improved logging to show that the env vars are being passed in properly (the port numbers aren't significant here, i tested in a new env).
Unfortunately I don't seem to have permissions to publish branches to this repo even though it's marked as public...
@talenta-eg commented on GitHub (Jun 13, 2023):
@conall88 Great job bro , does you right now can't login via email or Auth through HTTP ?
@conall88 commented on GitHub (Jun 13, 2023):
CORS directives do not require auth. the auth functionality provided by sh-admin isn't at issue here, i'm sure they work fine otherwise.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
@conall88 commented on GitHub (Jun 13, 2023):
please edit your post, you should not be sharing your oauth secrets.
they are called secrets for a reason, and i doubt you want a malicious actor taking your token and logging into services you auth via github.
That CORS error you posted is related to sentry APM, not hoppscotch. You need to configure your proxy accordingly.
For the graphQL post requests, check your Haproxy logs.
@cventastic commented on GitHub (Aug 17, 2023):
Hello,
im trying to understand this problem. (I use the 2023.08 release)
My .env - File has the following entries (i replaced my domain for privacy reasons):
The hoppscotch-app - container has no problem querying the backend:

and the hoppscotch-sh-admin - container cant query the backend i get:

I tried to set
but looking at the code it doesnt seem to do anything anyway.
What is the difference between hoppscotch-app - container querying the backend and hoppscotch-sh-admin - container querying the backend?
Update:
Since i use traefik i was able to work around this by creating my own cors headers for the backend container. i pasted the exact same values that are defined in WHITELISTED_ORIGINS env variable :
@AndrewBastin commented on GitHub (Sep 6, 2023):
@conall88 this should ideally be fixed in the 2023.8.0 release.
Please do recheck and reopen if the issue still persists.
Thanks ^_^
@conall88 commented on GitHub (Sep 6, 2023):
Awesome, il probably build the branch and check it out a little early,
thanks for your efforts 🙂
On Wed, 6 Sept 2023, 17:47 Andrew Bastin, @.***> wrote:
@cventastic commented on GitHub (Sep 11, 2023):
for me the problem still exists in 2023.08.0
@jk779 commented on GitHub (Oct 6, 2023):
Hi, sadly I'm still running in this problem: accessing graphql from the admin
I'm using this https://hub.docker.com/r/hoppscotch/hoppscotch Tag 2023.8.1 and added all domains to the whitelist.