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] NEXTAUTH_URL is missing/not set in Docker image #2880

Closed
1 of 2 tasks
ag-gaphp opened this issue Jul 11, 2024 · 3 comments
Closed
1 of 2 tasks

[BUG] NEXTAUTH_URL is missing/not set in Docker image #2880

ag-gaphp opened this issue Jul 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ag-gaphp
Copy link
Contributor

ag-gaphp commented Jul 11, 2024

Issue Summary

The Azure AD OAuth mechanism sends what looks like a hardcoded localhost address as the redirect URI when trying to sign in. However, I am not hosted at localhost and need it to redirect to the WEBAPP_URL that I specified in the Docker Compose yml.

Steps to Reproduce

  1. Setup Azure Tenant according to the Formbricks Docs
  1. Input the Client ID/Secret and Tenant ID to Formbricks
  2. Give Microsoft Entra ID an arbitrary redirect URL to your domain (the docs don't specify what the URI should be)
  3. Disable all other authentication methods
  4. Spin up the Formbricks service, then go to the URL for the setup wizard
  5. Attempt to sign-in using Azure
  • Observe: Microsoft error stating that the redirect URL does not match, gives an error that appears to indicate localhost might be hardcoded somewhere (or the WEBAPP_URL variable does not work)

Error Text:

AADSTS50011: The redirect URI 'http://localhost:3000/api/auth/callback/azure-ad' specified in the request does not match the redirect URIs configured for the application 'MY-APP-UUID'. Make sure the redirect URI sent in the request matches one added to your application in the Azure portal. 

Expected behavior

The redirect URL mentioned in the error message uses my defined WEBAPP_URL

Other information

I am not sure yet if localhost is hardcoded in the Azure mechanism, or if the Docker setup just isn't using this variable at all for anything. I will try to take a look through the repo and report back which it might be.

Screenshots

No response

Environment

  • Formbricks Cloud (app.formbricks.com)
  • Self-hosted Formbricks

Desktop (please complete the following information)

  • OS: NixOS 24.05 (Uakari)
  • Docker: v24.0.9
  • Formbricks Image: sha256:111d8546c3c74ec84e66faf8905bae0bfc5c618b5104998cd678411c797d9bef
@ag-gaphp ag-gaphp added the bug Something isn't working label Jul 11, 2024
@ag-gaphp ag-gaphp changed the title [BUG] Azure AD OAuth does not use the WEBAPP_URL or WEBAPP_URL is ignored in Docker setup [BUG] WEBAPP_URL is ignored in Docker setup Jul 11, 2024
@ag-gaphp
Copy link
Contributor Author

I'm not sure where it's falling apart, but I think it has something to do with Node and how it's pulling from the environment. I can shell into my container, and echo $WEBAPP_URL spits out the exact string I set in my Docker Compose. So Docker clearly has the variable set correctly, it's something that isn't getting imported properly in Node.

@ag-gaphp ag-gaphp changed the title [BUG] WEBAPP_URL is ignored in Docker setup [BUG] WEBAPP_URL is ignored in Docker image Jul 11, 2024
@ag-gaphp
Copy link
Contributor Author

I've just noticed a couple things in my logs for the web app that may be related.

  1. The output after startup finished says my URL is localhost, despite the Docker env having the correct URL
formbricks     | All migrations have been successfully applied.
formbricks     | npm notice
formbricks     | npm notice New minor version of npm available! 10.7.0 -> 10.8.2
formbricks     | npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2
formbricks     | npm notice To update run: npm install -g [email protected]
formbricks     | npm notice
formbricks     |   ▲ Next.js 15.0.0-rc.0
formbricks     |   - Local:        http://localhost:3000
formbricks     |   - Network:      http://0.0.0.0:3000
formbricks     |
formbricks     |  ✓ Starting...
formbricks     |  ✓ Ready in 159ms
  1. There is a warning from NextAuth regarding a missing URL variable
formbricks     | [next-auth][warn][NEXTAUTH_URL]
formbricks     | https://next-auth.js.org/warnings#nextauth_url

The doc page in the logs says that there needs to be a NEXTAUTH_URL defined. I set this variable in my Docker env and confirmed that it is set by shelling into the container. Although the NextAuth warning above disappears, I still see the localhost URL set as local in the logs.

I tested my login again, and this time the redirect URL is set properly in the error message.

Conclusion

It seems as though the container's CMD line, or Node itself, needs to set NEXTAUTH_URL to whatever the WEBAPP_URL to potentially fix this issue.

@ag-gaphp ag-gaphp changed the title [BUG] WEBAPP_URL is ignored in Docker image [BUG] NEXTAUTH_URL is missing/not set in Docker image Jul 11, 2024
@ag-gaphp
Copy link
Contributor Author

ag-gaphp commented Aug 2, 2024

Looks like this was resolved in 271ea89, closing

@ag-gaphp ag-gaphp closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant