Environment variable not being set correctly
Hi @evroon, thanks for creating this, it's great! I'm having an issue when updating from v1.5.3 to v2.0.0+. I get this error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8400/token. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 400
This is only when using a public endpoint instead of localhost. I have set NEXT_PUBLIC_API_BASE_URL to my public endpoint and this works fine on v1.5.3 but not on v2.0.0+. It looks as though this env var isn't being set for some reason. Could the bug detailed in this issue have come back?
https://github.com/evroon/bracket/issues/843
I've tested this on v2.0.0, v2.0.1 and v2.0.2 and all of them have the same issue. Let me know if you need any more info.
Ah that would be annoying, how do you set the environment variable? Do you pass it in docker-compose or do you build the image yourself using this variable?
And thanks for looking at the existing issue, troubleshooting and testing it on multiple releases btw!
Thanks for the quick response! I'm setting it in docker-compose, like this:
services:
...
bracket-frontend:
container_name: bracket-frontend
environment:
NEXT_PUBLIC_API_BASE_URL: "https://api.tournament.abc.xyz"
NEXT_PUBLIC_HCAPTCHA_SITE_KEY: "10000000-ffff-ffff-ffff-000000000001"
NODE_ENV: production
image: ghcr.io/evroon/bracket-frontend:v2.0.1
ports:
- 3000:3000
restart: unless-stopped
...
No worries, I know how much easier troubleshooting is when you as much info as possible! Let me know if there are any other settings that'd help troubleshoot or anything you'd like me to try to test :)
I tried it and for me it does work when I run this:
sudo docker run -e NEXT_PUBLIC_API_BASE_URL=http://localhost:3400 -p 3000:3000 --name frontend ghcr.io/evroon/bracket-frontend:v2.0.1
Then you can remove that container and try again with a new port 6800:
sudo docker rm -f frontend
sudo docker run -e NEXT_PUBLIC_API_BASE_URL=http://localhost:6800 -p 3000:3000 --name frontend ghcr.io/evroon/bracket-frontend:v2.0.1
And then if you press CTRL + F5 in the browser (or disable caching), you should see that it now uses 6800 as port.
It didn't work for me a while until I figured out F5 keeps that old port in the memory cache because it caches the file that looks like http://localhost:3000/_next/static/chunks/pages/login-77b4c01f11fea9d6.js
@dickravison Could you let me know if this solves the issue for you?
@evroon, sorry for commenting on an old issue, but i think the OP was running the container with a different NEXT_PUBLIC_API_BASE_URL like in #843 . I'm seeing the same issue as #843 in the current image (as of 5/20/2025).
Perhaps there was a regression? I'm still seeing POST http://localhost:8400/token net::ERR_CONNECTION_REFUSED in the browser console (on a different machine - other than the headless docker host) despite having a different ip set in NEXT_PUBLIC_API_BASE_URL in the docker compose.
i am having the same issues as @meichthys
Hmm I tried this last week and i had no problems. What exactly is the docker-composr file you use?
services: bracket-frontend: image: ghcr.io/evroon/bracket-frontend container_name: bracket-frontend ports: - "3000:3000" environment: NODE_ENV: "production" NEXT_PUBLIC_API_BASE_URL: "http://192.168.1.15:8400" NEXT_PUBLIC_HCAPTCHA_SITE_KEY: restart: unless-stopped
bracket-backend:
image: ghcr.io/evroon/bracket-backend
container_name: bracket-backend
ports:
- "8400:8400"
environment:
ENVIRONMENT: "PRODUCTION"
PG_DSN: "postgresql://bracket_prod:password@postgres:5432/bracket_prod"
CORS_ORIGINS: https://domain.com
JWT_SECRET: e7b8f3a0b2d43cf94a6f6cc5f17cd3bb1eb7e7316eab48ac6f6e7db7e0a34e5f
volumes:
- /volume1/docker/bracket/backend/static:/app/static
restart: unless-stopped
depends_on:
- postgres
postgres:
image: postgres
restart: always
environment:
POSTGRES_DB: bracket_prod
POSTGRES_USER: bracket_prod
POSTGRES_PASSWORD: password
volumes:
- /volume1/docker/bracket/postgres:/var/lib/postgresql/data
btw i am running this compose on portainer on a synology.
when i run the development compose i get the same issues.
networks: bracket_lan: driver: bridge
services: bracket-backend: container_name: bracket-backend depends_on: - postgres environment: ENVIRONMENT: DEVELOPMENT CORS_ORIGINS: http://localhost:3000 PG_DSN: postgresql://bracket_dev:bracket_dev@postgres:5432/bracket_dev image: ghcr.io/evroon/bracket-backend networks: - bracket_lan ports: - 8400:8400 restart: unless-stopped volumes: - /volume1/docker/bracket/backend/static:/app/static
bracket-frontend: container_name: bracket-frontend environment: NEXT_PUBLIC_API_BASE_URL: http://localhost:8400 NEXT_PUBLIC_HCAPTCHA_SITE_KEY: 10000000-ffff-ffff-ffff-000000000001 image: ghcr.io/evroon/bracket-frontend ports: - 3000:3000 restart: unless-stopped
postgres: environment: POSTGRES_DB: bracket_dev POSTGRES_PASSWORD: bracket_dev POSTGRES_USER: bracket_dev image: postgres networks: - bracket_lan restart: always volumes: - /volume1/docker/bracket/postgres:/var/lib/postgresql/data
if i change the NEXT_PUBLIC_API_BASE_URL to something else i still get the error con. refused on localhost:8400. Looks like the env is not picking up.
And what do the logs say of the frontend container?