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

feat: include BASE_PATH when redirecting to welcome #267

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ check whether the session is valid or not.
There are two ways of serving this application under a base path:

1. Let Express.js handle the routing by setting the `BASE_PATH` environment
variable to the sub-path, e.g. `/myapp`.
variable to the sub-path, e.g. `/myapp`. (without trailing slash)
2. Use a reverse proxy or API gateway to strip the path prefix.

The second approach is not always possible, especially when running the
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ registerWelcomeRoute(router)
registerErrorRoute(router)

router.get("/", (req: Request, res: Response) => {
res.redirect(303, "welcome")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is on purpose so that the redirect to welcome is relative and not absolute

Copy link
Author

@pucke-dev pucke-dev Jul 9, 2023

Choose a reason for hiding this comment

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

I think its still relative, but prefixed with a base path. When using BASE_PATH env the /welcome route also moves to BASE_PATH/welcome, so this redirect shoots into nowhere, and I would ague, this is a inconsistent behavior compared to the other routes. Pls correct me if im wrong @aeneasr

res.redirect(303, `${baseUrl}/welcome`)
})

registerStaticRoutes(router)
Expand Down
Loading