Repository navigation
[Request] Custom URL base path support #415
Description
Activity
- changed the title
[-]Custom URL base path support[/-][+][Request] Custom URL base path support[/+]on Oct 4, 2025 I don't understand the problem. If you have a
https://splitpro.example.comand set it as theNEXTAUTH_URLthis should work properly. This is how I personally use it and there is no problem with such a solution. If I understand correctly from your brief description then that it is possible and you might have something misconfigured in nginx.- addedquestionFurther information is requestedFurther information is requested
on Oct 4, 2025 Ill elaborate on the issue.
Lets say i own the domain https://sub.domain.com/I have 3 application on the server:
https://sub.domain.com/db
https://sub.domain.com/logs
https://sub.domain.com/homeThis are not PAGES. Each path being routes to 3 different containers using an nginx reverse proxy.
Thats allows me to have multiple apps running on a single server and accessible rasily behind a single nginx.
I want to have https://sub.domain.com/splitpro.
Problem is if the nginx redirect this url to the splitpro container, it wont work since it expected to recieve non relative paths
In this project. We can add baseUrl to the nextJS config, but then we have to rebuild it.
Thats bad because it means i wouldnt be able to receive updates from dockerhub.I would like to have an environment variable thats changed the basePath when the container starts.
This is a very common problem and most web project have such variable so we dont have to invent the wheel here, just make sure it is integrated correctly.
Example of nginx proxy (so its easier to understand):
events {} http { server { listen 80; server_name yourdomain.com; location /app1/ { proxy_pass http://app1:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /app2/ { proxy_pass http://app2:5000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /app3/ { proxy_pass http://app3:3000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } }Subpath routing is also possible out of the box. It's been a while since I used nginx, but maybe try removing the trailing slashes in your config, so it's like
location /splitpro { proxy_pass http://splitpro:3000; }Subpath routing is also possible out of the box. It's been a while since I used nginx, but maybe try removing the trailing slashes in your config, so it's like
location /splitpro { proxy_pass http://splitpro:3000; }This will definitely work for the first request. Problem is - if the page has a link to another resource, it will try to fetch it relative to / and will no longer reach the correct location tag.
The internal wrb server must be aware of the subpath
Did you add the base path to the
NEXTAUTH_URLenv var?Did you add the base path to the
NEXTAUTH_URLenv var?NextAuth isn't relevant to this feature. just to make sure I'm not missing anything - i did change it, obviously it had no relevant effect.
My feature request is about the web server itself. nextauth is just about authentication and its really no the issue here.
for me to use this very cool project - i need to be able to change all of the pages and resources to response to request with prefixes like /splitpro/home instead of /home.NextJS natively supports that with basePath but only in build time (npm build).
if ill use the basePath solution i would be able to receive updates from docker hub since ill have to build the docker myself. which is a bummer in terms of maintenance.
This is a famous problem around the internet, I'm no inventing the wheel here. Some have acceptable solutions but the root issue is NextJS is too simple for proper web apps and does not support simply supports this like other frameworks.
i don't really mind what's the solution but i cannot host this project until there is one since i only have a single subdomain.
Thank you for the attention anyway, appreciated.
You're right, I also did some reading and seems like a major NextJS bummer.
We also use the NEXT_AUTH variable for baseUrl logic, that's why I asked, but of course it does not affect Next internals. What solution are you proposing then, out of the acceptable solutions? I could add a build argument to our dockerfile for setting thebaseUrlin config, but don't really see how else I could help you.The solutions i can think of are:
-
changing NextJS to a more modern framework like vite+react-router.
from personal experience - it either works without issue or some imports failed and then its terrible. -
find & replace all of the resources link and using assetsPath variable.
This is either very easy or very hard depending on the project structure which i haven't looked at.
would also require changing the dev conventions to use a wrapper or something.
I think the first solution has many advantages since the project isn't static anyway (like SSR and such).
Sadly they are both kinda heavy :(I'll continue to watch for a while to see if it is fixed. thank you.
-
Well I hope I don't have to explain why both of these are a no go for me as for now. Let's hope that Vercel ships a more proxy friendly solution, but sadly self hosting does not really fit their business model.
i slept on it, i realized that maybe building the docker myself isn't too bad.
At first i had a bad experience with the building since it build the image in one file but the docker-compose is another. separated to dev and prod.
Very messy very unclear and might change in future versions.I think i will have the confident to build it myself if we can change the building to a single
docker-compose up --build -dcommand.
and then updating would just begit pull.
This only requires adocker-compose.ymlfile that has a dedicated .env file and builds and setup a production ready env.
This will require the devs to never break this convention (not too bad i think).I'll be happy to change everything myself or help with it if we can make sure that we keep this in future version, waiting for your approval.
Semi-related: Does the project have an update notification somewhere? what is the proper solution to making sure I'm using the latest version.
Again, thank you for being so cooperative. Eventually we have to win SplitWise the evil devil...
Sorry for the delayed response. Regarding the compose file, why not just copy it to the root of your project and slightly modify it:
name: split-pro-prod services: postgres: image: postgres:16 container_name: ${POSTGRES_CONTAINER_NAME:-splitpro-db} restart: always environment: - POSTGRES_USER=${POSTGRES_USER:?err} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?err} - POSTGRES_DB=${POSTGRES_DB:?err} - POSTGRES_PORT=${POSTGRES_PORT:-5432} healthcheck: test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'] interval: 10s timeout: 5s retries: 5 volumes: - database:/var/lib/postgresql/data splitpro: build: . # <--- This will automatically build a local image container_name: splitpro restart: always ports: - ${PORT:-3000}:${PORT:-3000} environment: - PORT=${PORT:-3000} - HOSTNAME=0.0.0.0 depends_on: postgres: condition: service_healthy volumes: database:
The
docker composecommand will automatically include a.envfile in the same directory, which you can create based on the example file.
No notification sadly, you can add submit a PR with a check for that if you'd like. Otherwise just star the repo and visit Github from time to time and you'll see the releases on your dashboard.
- locked and limited conversation to collaborators
on Oct 17, 2025
Is your feature request related to a problem? Maybe it would be better as discussion? Please describe.
when hosting multiple web applications under a single domain, the / path is taken by a single app
Describe the solution you'd like
Would like to configure an external nginx reverse proxy for /splitpro to go into the splitpro web container.
Describe alternatives you've considered
im already using a subdomain.
Making nginx change url prefixes break web resources paths
App version
Latest