Repository navigation
feat(.well-known): add .well-known/immich to reference API endpoint - #1308
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
If I understand correctly, the user still needs to fill in the server URL input on the mobile app, correct? |
jrasm91
left a comment
There was a problem hiding this comment.
Looks good to me. I haven't figured out how to build the mobile app locally yet, otherwise I would have tested OAuth, but looking at the code I don't see why there would be any problems.
RE: duplicate code. I'm not a mobile developer, but maybe it'd be worth adding a resolve: boolean as a second argument to setEndpoint() and then moving the validate call inside of that method. It looks like it runs pretty much all the time, except when the backup service loads the value.
Yes, the user will still need to enter a server URL, but this URL can now be the base web URL rather than the full API endpoint (ex: Also, as per the discussions in #614, it allows several short hands. Namely, if only a
Thanks for the feedback! I'd be happy to combine them if we want. A few minor thoughts on why I feel it may be better to kept them separate, though:
Instead of removing/changing |
|
Let me know when the PR is ready for a throughout review |
025b4d2 to
a485bb2
Compare
|
I think translations are pulled from an external source, right @alextran1502 ? |
|
Correct
…On Sat, Jan 14, 2023 at 8:09 PM Jason Rasmussen ***@***.***> wrote:
I think translations are pulled from an external source, right
@alextran1502 <https://github.com/alextran1502> ?
—
Reply to this email directly, view it on GitHub
<#1308 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGONL7XFBIKTZ6A2H7CQSKTWSNL53ANCNFSM6AAAAAATYWIKCI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Good to know, thanks! In the context of this PR what do I need to do then? Do I only update the
@alextran1502 Other than updating the translations, I think this PR is now ready for a more thorough review. |
Correct, you only need to update the |
| # Use a full URL here if you want to serve the API via a dedicated domain. | ||
| #################################################################################### | ||
|
|
||
| IMMICH_SERVER_PUBLIC_URL=/api |
There was a problem hiding this comment.
The environmental name is a bit confusing :-? I wonder if we have any other wording that can make it clearer to provide the example in the info box?
There was a problem hiding this comment.
Yeah, I definitely struggled to think of a good name here, largely because IMMICH_SERVER_URL and IMMICH_WEB_URL were already taken to mean the internal/private locations for those services, and this is effectively the public facing version of those. A few alternatives I'd been considering: IMMICH_PUBLIC_SERVER_URL, IMMICH_EXTERNAL_SERVER_URL, IMMICH_SERVER_URL_EXTERNAL, etc. Alternatively, we could be super explicit with somethineg like: IMMICH_WELLKNOWN_SERVER_URL.... but I am very open to suggestions!
I also tried updating the comment and example a bit, to hopefully make it clearer. Let me know if you think that helps at all.
There was a problem hiding this comment.
I prefer IMMICH_API_URL_EXTERNAL, as it's for the API, not the server. Otherwise, IMMICH_SERVER_URL_EXTERNAL might work?
It's distinct from IMMICH_SERVER_URL (used for internal communication), and distinct from the web URL (which doesn't need/use a variable).
In some cases, all three URLs may be the same, but that's not necessarily always the case.
There was a problem hiding this comment.
Thanks, that sounds good to me, I've switched it to "IMMICH_API_URL_EXTERNAL". I really like the idea of adding API in there, as that truly is what the URL represents, but I originally wasn't sure if we should introduce a new term (seems how everywhere else its still referenced as the more ambiguous "server").
|
Everything looks good! I test on Oauth instance and it can detect the OAuth login button. Besides a small comment about the variable name and revert back the changes for other translation file besides English. We are good to go. I will merge this in once we resolved the topics above. |
0259228 to
b9dd39e
Compare
| # Examples: http://localhost:3001, http://immich-api.example.com, etc | ||
| #################################################################################### | ||
|
|
||
| IMMICH_SERVER_PUBLIC_URL=http://localhost:3001 |
There was a problem hiding this comment.
I believe we made some mistakes here. I've tested this scenario and the web cannot be accessed. I am accessing the web through http://local-ip:2283
And for any optional config, shouldn't it be starting out as a commented line?
There was a problem hiding this comment.
Re: optional configuration: I commented out the default value from the .env.example. Although, it doesn't look like any other optional environment variables are commented it, so would just leaving "blank" be more inline with the current convention?
As for accessing from the web being broken, looks like you are right, thanks for catching that. I had previously only tested as far as logging in, and didn't actually try any actions once logged in. I now see that all the client-side API requests return 401s when the API is served on a separate domain name. This is because the web project (both browser and server side) never actually set the immich-access-token cookie, and instead relies on the API server to directly set this (which doesn't work when on separate domain names).
I have created a "temporary" fix for this, by setting the cookie from the web project, and ensuring setAccessToken is called both in browser and on the server side (of the web project). HOWEVER, I think a more permanent solution should be consider to address this properly. Do you think I should look to address this here, or make a separate Issue to improve this later?
|
@conneryn is attempting to deploy a commit to the immich Team on Vercel. A member of the Team first needs to authorize it. |
|
I don't think we need to set the access token in the web anywhere because it should use https secure cookies, etc. |
|
The server API uses an access token, the client API uses http only, secure cookies for authentication. https://github.com/immich-app/immich/blob/main/web/src/routes/+layout.server.ts |
This is correct |
|
@jrasm91, there are a few issues with the current usage of cookies and client access:
|
Have you tried testing this scenario I believe the three variables below are for this purpose I have a feeling this PR has gone a bit too far from its original intention. I think the idea is to have the |
…ken" This reverts commit 60e3389.
|
For clarification each request that svelte handles has its own context/scope if I'm not mistaken. Every request passes through layout.server.ts and parses/sets the access token. It is not shared between users, requests, etc., and not a secretary concern. Yes, different domains would indeed cause an issue, I missed that was what you were trying to solve. I think there are multiple ways to solve this problem though, and I don't know if this is the right forum to have that discussion and make that decision. Svelte itself can function as a reverse proxy, and still uses cookies from the server, we could send API requests with include credentials, or we could switch to access token via bearer auth. There are pros and cons to each and it might be worthwhile to investigate them and address that specific use case (API on a different domain) in another PR. I'd be down to continue a conversation about implementing in discord though if you want to start a thread on the topic. |
|
@alextran1502 I'm fine with simplifying this PR to only address the Re: Service Addresses. Unfortunately, the three variables mentioned won't quite help in this case. I think those are intended to be internal addresses, as they are used by NGINX (and other services) for backend routing, and not actually exposed to end-user/clients. |

This PR is intended to resolve #614 . This is also an attempt for me to get more familiar with the code base, I'm hoping to be able to contribute in more meaningful ways, eventually.
Primary goal:
Add a
/.well-known/file to the web server project that can direct clients (web and mobile) to the appropriate backend API URL.Solution:
IMMICH_SERVER_PUBLIC_URLenvironment variable that can be used to override the default/apirelative path for the API. I can be another relative path, or a separate domain altogether (ex:api-immich.example.com)/.well-known/immichroute to thewebproject that returns a JSON payload (ex:{ "api": { "endpoint": "https://api-immich.example.com" } }).well-knownfile first, and use the endpoint, if found. If not found, the app fallbacks on assuming the URL provided by the user already points to the API (for backwards compatibility).In order to make it possible to serve the API via a separate domain name, a few other changes were required:
ALLOW_CORS_ORIGINenvironment variable, which can be used to enable cors (previously, only development builds had this enabled).Questions for reviewers:
apiService(ex: as aresolveAndSetEndpoint()method), but I wasn't sure if that would be an acceptable location to be accessingHiveboxes.oauth, so any help testing/validating that flow works as expected would be much appreciated.