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

fix: login fallback error #19410

Merged
merged 4 commits into from
Dec 11, 2024
Merged

Conversation

Chisomchima
Copy link
Member

@Chisomchima Chisomchima commented Dec 9, 2024

Implements DHIS2-18585

Description:

This pull request addresses an issue with the login page where the dynamic base URL was not considering the URL context path (e.g., /dev, /prod). Without this fix, the application attempted to send the authentication request to the wrong endpoint (/api/auth/login instead of /dev/api/auth/login), leading to a failure when hosted under specific context paths like /dev.

Changes:

  • Base URL Calculation:
    • Updated the getBaseUrl() function to account for the context path (e.g., /dev, /dev-2-41, etc.) in the URL.
    • The context path is now correctly appended to the API endpoint, ensuring that requests like POST /api/auth/login are sent to /dev/api/auth/login when the app is hosted under /dev.
    • If the page URL ends with login.html, that part is correctly stripped off while preserving the context path.

Problem Addressed:

  • Before this change, when the app was hosted under a context path (e.g., /dev/login.html), the login form submitted requests to http://localhost:8080/api/auth/login instead of the expected /dev/api/auth/login.
  • This caused authentication requests to fail for applications hosted in a subdirectory or versioned environment.

@tomzemp tomzemp self-requested a review December 9, 2024 15:36
Copy link
Member

@tomzemp tomzemp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@tomzemp tomzemp requested a review from netroms December 11, 2024 08:07
Copy link

sonarcloud bot commented Dec 11, 2024

@Chisomchima Chisomchima merged commit 2cc2920 into master Dec 11, 2024
16 checks passed
@Chisomchima Chisomchima deleted the DHIS2-18585/login-fallback-error branch December 11, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants