Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: CORS prevents signup when running locally via docker-compose up #251

Closed
theronic opened this issue Jun 27, 2023 · 7 comments
Closed
Assignees
Labels
issue: help wanted Issue needing extra attention

Comments

@theronic
Copy link

theronic commented Jun 27, 2023

(edit: accurate compose command to overrides ports)

Describe the bug

Access to fetch at 'http://localhost:3000/graphql' from origin 'http://localhost:8081' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

To Reproduce
Steps to reproduce the behavior:

gh repo clone getlago/lago
FRONT_URL=http://localhost:8081 POSTGRES_PORT=5433 FRONT_PORT=8081 docker-compose up

Now open frontend on port 8081 and try to sign up. Frontend loads but API doesn't start because Postgres doesn't start.

Expected behavior
should not fail

Screenshots
image

Support
macOS, Brave.

@theronic
Copy link
Author

Note: I did set FRONT_URL which should feed into the rake-cors CORS settings.

Command to run:

FRONT_URL=http://localhost:8081 POSTGRES_PORT=5433 FRONT_PORT=8081 docker-compose up

(Aside: docker-compose does not exit when I press Ctrl+C.)

@mathieu-lago mathieu-lago added the issue: help wanted Issue needing extra attention label Jun 27, 2023
@theronic
Copy link
Author

Hmmk so FRONT_URL was setting CORS settings but Postgres was not starting even though POSTGRES_PORT was set.

So new bug: Lago does not honour POSTGRES_PORT override, or maybe Postgres refuses to start. Probably port mapping issue.

@jdenquin
Copy link
Contributor

@theronic so the CORS issue is resolved?
It's always around the LAGO_FRONT_URL defintion for the api service for this kind of errors, we will add more info on the doc about this.

Can you share some errors or informations about the POSTGRES_PORT issue? On the code side, backend don't know about port because we use DATABASE_URL so everything is around the docker configuration here!

@jdenquin
Copy link
Contributor

just adding, can you check that you are on the main branch of the repo? Github had a bug yesterday and was routing by default to an other branch

@Alexey2257
Copy link

Alexey2257 commented Jul 1, 2023

The issue is seemed to be in api environment, we should use 5432 port here, not port from env
works for me while using POSTGRES_PORT=5433:

- DATABASE_URL=postgresql://${POSTGRES_USER:-lago}:${POSTGRES_PASSWORD:-changeme}@db:5432/${POSTGRES_DB:-lago}

@jdenquin
Copy link
Contributor

jdenquin commented Jul 5, 2023

if you use the 5432 port in the docker network yes, I'll update the docker-compose file this way

ports:
      - ${POSTGRES_PORT:-5432}:${POSTGRES_PORT:-5432}

@jdenquin
Copy link
Contributor

jdenquin commented Jul 7, 2023

fixed in #254

@jdenquin jdenquin closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: help wanted Issue needing extra attention
Projects
None yet
Development

No branches or pull requests

4 participants