[Feature] Support base url on the web app #1679
Replies: 25 comments 31 replies
-
I think the problem here is that you have |
Beta Was this translation helpful? Give feedback.
-
Do you mean that Immich-web can run only in root path? Another files are downloaded properly. The problem is only in Web-app, and is related only to |
Beta Was this translation helpful? Give feedback.
-
I might have the wrong assumptions. I think what you do is fine, it seems the proxy is working fine as well. I am not sure why that file isn't loaded correctly. Let me do some digging. At the mean time, can you try to pull |
Beta Was this translation helpful? Give feedback.
-
All containers are up-to-date:
|
Beta Was this translation helpful? Give feedback.
-
@usikpavel Immich web can not work perfectly with path prefix now because of web framework config. You'd better use mobile only if you still wanna use path prefix, or use subdomain instead. I hope immich team will @alextran1502 I have a small test with web, Svelte kit not support base url perfectly because |
Beta Was this translation helpful? Give feedback.
-
I have problem using HAProxy as SSL termination using something like https://domain.com/immich I added ACL to manage /immich and /fonts/*** but does not work. |
Beta Was this translation helpful? Give feedback.
-
Wanting run Immich under a path using a duckdns address, I am running into this issue as well. I believe this is the related Svelte issue |
Beta Was this translation helpful? Give feedback.
-
I ran into this issue when I tried to publish Immich using Tailscale Funnel, which currently doesn't support subdomains. It'd be great if Immich could support this. |
Beta Was this translation helpful? Give feedback.
-
I ran into the same issue and would like it if it was possible to run immich under a subpath |
Beta Was this translation helpful? Give feedback.
-
I need to use a baseurl this is really the only choice I have but luckily every single other app I want to host has supported this. I thought it was a pretty basic feature after all every app can't take the root of the server. Is it true that immich cannot do this: I will not be able to use immich until this is supported. Can anyone confirm that immich does not support base url and that there are no plans to support it in the futture before I invest more time into looking for a solution. |
Beta Was this translation helpful? Give feedback.
-
This is exactly what I need, as well. Been trying all kinds of Traefik tricks, but it would seem the config needs to be set a a lower layer. Hoping someone has figured that out. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
What a measured and mature response. It’s refreshing from developers, certainly devs working for free. You just made a fan for life! |
Beta Was this translation helpful? Give feedback.
-
Is this still not supported by Sveltekit? I am in the same boat (trying to setup Immich+Caddy behind tailscale) and just cannot get it to work. The docs seem to imply that it is doable, but maybe I am misreading? (see also sveltejs/kit#595) Would appreciate if you could take another look at this, beacuse I am kinda stuck. ❤️ |
Beta Was this translation helpful? Give feedback.
-
Adding my 2 cents here. This feature would be very useful to lots of people, including me i guess. I cannot (don't know how) add this myself, so i hope somebody can chime in. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I'm running Immich on the LAN, hence I can't create a subdomain. an environment variable such as |
Beta Was this translation helpful? Give feedback.
-
I've created an nginx config for those who need this to work now: But this is no long term solution of course, it would be great if immich would support this out of the box. It shouldn't be that hard to implement because Sveltekit already supports base urls, in fact the nginx config rewrites the Sveltekit config and sets the base path. |
Beta Was this translation helpful? Give feedback.
-
To properly support reverse proxies that change the base url we could implement the |
Beta Was this translation helpful? Give feedback.
-
It works! Maybe it can be added to the immich documentation while waiting for the discussion to reach a consensus? |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using ngin reverse proxy manager with already a home assistant instance using my root path + a specific custom location aka subpath config for a overseerr instance pointing to domain/overseerr. I'd love to see this base url feature make it at some point! |
Beta Was this translation helpful? Give feedback.
-
My use case was highlighted earlier on in this post, but I will reverberate it for clarity: Using tailscale funnel is a convenient way for me to expose my Immich server to the internet. However, you have no control over the domain part ( This forces you to use path qualifiers (such as |
Beta Was this translation helpful? Give feedback.
-
Having a quick look at the relevant code when creating the server, this feature might be a matter of simply patching this code to be base-path aware. Calling app.setGlobalPrefix(`${customBasePath + '/'}api`, { exclude: excludePaths }); and then it is a matter of patching the other paths served. The main problem might be The more trivial solution might be just to create a Nest middleware to rewrite responses. |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
Hi all, I’ve come up with a workaround to host Immich with a predefined prefix. I am not an expert in web developing, so please feel free to point out mistakes if there's any! ;) TL;DRThe core idea is to ensure that "routing actions" are handled by SvelteKit, which appends the base path to internal URLs. The solution requires YOU pre-defining the prefix, compiling the code, and hosting the web app on an external HTTP server. The modified web app runs alongside the official Docker image, and these two parts are put together by an Nginx server. Steps:
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
paths: {
base: '/immich',
},
},
};
location /immich/ {
root /usr/share/nginx/html/;
try_files $uri /immich/index.html;
location ~ /immich/api(.*) {
client_max_body_size 0;
proxy_request_buffering off;
proxy_buffering off;
proxy_pass http://immich_server:3001;
rewrite /immich/(.*) /$1 break;
# Reverse proxy settings from Immich
proxy_set_header Host $http_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;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
# Timeout settings
proxy_read_timeout 600s;
proxy_send_timeout 600s;
send_timeout 600s;
}
} However I couldn’t find a good solution for a dynamic prefix (i.e., one defined before compiling or generated on the fly). There are too many restrictions in the Immich codebase and the SvelteKit framework. I also found a potential solution if we can make some further adjustments, but it may conflict with the maintainers’ intent. I’m happy to share if anyone is interested! :) Web App SideStatic Assets:Immich is built as a client-side rendered single-page app (SPA), and SvelteKit won’t generate relative links for SPAs, which affects the URLs for static assets. From the SvelteKit documentation:
According to discussions from other SvelteKit projects, partly rendering the file at the server side could help. However, since the Immich web app is built as a static file bundle, the best we can do is define the base URL before compiling. Relevant issues of SvelteKit: #595, #9569, and #10235 OpenAPI Base URL:API URLs are defined in the OpenAPI SDK with the base URL specified in the same file: immich/open-api/immich-openapi-specs.json Lines 7401 to 7405 in aa0097b Since exported methods rely on this base URL, you can either define the value before compiling, or set it dynamically in The latter approach avoids modifying the OpenAPI configuration and IMO is more suitable for a dynamic base URL (if that becomes possible in the future). URL Routing:This is the tricky part. The routing paths are defined by the immich/web/src/lib/constants.ts Lines 14 to 51 in aa0097b These route links are used in these 3 actions but none of them handle the
The This function handles the Server SideThere are nothing to do with the server since the nginx can handle the proxying very well at this moment. What we have to do is just fix some bugs that caused by the transparent proxying. For example, the logout API returns a hard-coded 302 which won't integrate with the client-side URL: immich/server/src/services/auth.service.spec.ts Lines 183 to 221 in aa0097b |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Immich server is deployed using default docker-compose.yml on the private host (Windows10) at
http://192.168.3.3:2283/
It is accessible via reverse proxy (Windows Server 2019, IIS 10) at public url http://pavelusik.ru/photosImmich/
Main page is loaded successfully, but is not working. The reason is that
/_app/immutable/start-a8372751.js
file relative path is wrong:and therefore error 404 occured.
All other files (css, js, json, favicon, etc) are loaded successfully by their correct relative addresses
/photosImmich/...path...
Task List
docker-compose
file..env
file.To Reproduce
Steps to reproduce the behavior:
Expected behavior
/photosImmich/...path...
System
v1.25.0_35-dev
onWindows 10
running indocker
Windows Server 2019
,IIS 10 (with modules URL Rewrite 2, Application Request Routing 3.0)
Additional context
docker-compose and env.zip
Beta Was this translation helpful? Give feedback.
All reactions