diff --git a/docker/.env.example b/docker/.env.example index e24a0208bb..18c96c3534 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -56,21 +56,6 @@ ENABLE_MAPBOX=false MAPBOX_KEY= - - -################################################################################### -# WEB - Required -################################################################################### - -# This is the URL of your vm/server where you host Immich, so that the web frontend -# know where can it make the request to. -# For example: If your server IP address is 10.1.11.50, the environment variable will -# be VITE_SERVER_ENDPOINT=http://10.1.11.50:2283/api -# !CAUTION! THERE IS NO FORWARD SLASH AT THE END - -VITE_SERVER_ENDPOINT= - - #################################################################################### # WEB - Optional #################################################################################### diff --git a/server/apps/immich/src/config/app.config.ts b/server/apps/immich/src/config/app.config.ts index b2509db908..304bee8643 100644 --- a/server/apps/immich/src/config/app.config.ts +++ b/server/apps/immich/src/config/app.config.ts @@ -16,6 +16,5 @@ export const immichAppConfig: ConfigModuleOptions = { then: Joi.string().optional().allow(null, ''), otherwise: Joi.string().required(), }), - VITE_SERVER_ENDPOINT: Joi.string().required(), }), }; diff --git a/server/entrypoint.sh b/server/entrypoint.sh deleted file mode 100644 index 9f35169bf6..0000000000 --- a/server/entrypoint.sh +++ /dev/null @@ -1 +0,0 @@ -npm start immich \ No newline at end of file diff --git a/web/src/api/api.ts b/web/src/api/api.ts index 12b7dee9a8..d8454350ec 100644 --- a/web/src/api/api.ts +++ b/web/src/api/api.ts @@ -16,7 +16,7 @@ class ImmichApi { public authenticationApi: AuthenticationApi; public deviceInfoApi: DeviceInfoApi; public serverInfoApi: ServerInfoApi; - private config = new Configuration({ basePath: serverEndpoint }); + private config = new Configuration({ basePath: '/api' }); constructor() { this.userApi = new UserApi(this.config); @@ -34,6 +34,12 @@ class ImmichApi { public removeAccessToken() { this.config.accessToken = undefined; } + + public setBaseUrl(baseUrl: string) { + this.config.basePath = baseUrl; + } } export const api = new ImmichApi(); +export const serverApi = new ImmichApi(); +serverApi.setBaseUrl('http://immich-server:3001'); diff --git a/web/src/hooks.ts b/web/src/hooks.ts index 44f9a33e0d..788f169eb0 100644 --- a/web/src/hooks.ts +++ b/web/src/hooks.ts @@ -1,6 +1,6 @@ import type { ExternalFetch, GetSession, Handle } from '@sveltejs/kit'; import * as cookie from 'cookie'; -import { api } from '@api'; +import { api, serverApi } from '@api'; export const handle: Handle = async ({ event, resolve }) => { const cookies = cookie.parse(event.request.headers.get('cookie') || ''); @@ -11,8 +11,8 @@ export const handle: Handle = async ({ event, resolve }) => { const accessToken = cookies['immich_access_token']; try { - api.setAccessToken(accessToken); - const { data } = await api.userApi.getMyUserInfo(); + serverApi.setAccessToken(accessToken); + const { data } = await serverApi.userApi.getMyUserInfo(); event.locals.user = data; return await resolve(event); diff --git a/web/src/lib/components/album-page/album-viewer.svelte b/web/src/lib/components/album-page/album-viewer.svelte index b9098f8a84..9d18e1ff0b 100644 --- a/web/src/lib/components/album-page/album-viewer.svelte +++ b/web/src/lib/components/album-page/album-viewer.svelte @@ -60,7 +60,7 @@ }); $: { - if (album.assets.length < 6) { + if (album.assets?.length < 6) { thumbnailSize = Math.floor(viewWidth / album.assets.length - album.assets.length); } else { thumbnailSize = Math.floor(viewWidth / 6 - 6); diff --git a/web/src/lib/components/shared-components/status-box.svelte b/web/src/lib/components/shared-components/status-box.svelte index 1fecc700b4..fe92641a9a 100644 --- a/web/src/lib/components/shared-components/status-box.svelte +++ b/web/src/lib/components/shared-components/status-box.svelte @@ -82,11 +82,6 @@
Server
-Status
diff --git a/web/src/lib/stores/assets.ts b/web/src/lib/stores/assets.ts index 35865b022f..107a98763f 100644 --- a/web/src/lib/stores/assets.ts +++ b/web/src/lib/stores/assets.ts @@ -29,3 +29,7 @@ export const getAssetsInfo = async () => { console.log('Error [getAssetsInfo]'); } }; + +export const setAssetInfo = (data: AssetResponseDto[]) => { + assets.set(data); +}; diff --git a/web/src/lib/utils/file-uploader.ts b/web/src/lib/utils/file-uploader.ts index edcdcdaa7d..8c1aa6be55 100644 --- a/web/src/lib/utils/file-uploader.ts +++ b/web/src/lib/utils/file-uploader.ts @@ -168,7 +168,7 @@ async function fileUploader(asset: File, uploadType: UploadType) { uploadAssetsStore.updateProgress(deviceAssetId, percentComplete); }; - request.open('POST', `${serverEndpoint}/asset/upload`); + request.open('POST', `api/asset/upload`); request.send(formData); } catch (e) { diff --git a/web/src/routes/admin/index.svelte b/web/src/routes/admin/index.svelte index 8da545eba1..641821802d 100644 --- a/web/src/routes/admin/index.svelte +++ b/web/src/routes/admin/index.svelte @@ -2,10 +2,12 @@ import type { Load } from '@sveltejs/kit'; import { api, UserResponseDto } from '@api'; - export const load: Load = async () => { + export const load: Load = async ({ fetch }) => { try { - const { data: allUsers } = await api.userApi.getAllUsers(false); - const { data: user } = await api.userApi.getMyUserInfo(); + const [user, allUsers] = await Promise.all([ + fetch('/data/user/get-my-user-info').then((r) => r.json()), + fetch('/data/user/get-all-users?isAll=false').then((r) => r.json()) + ]); return { status: 200, diff --git a/web/src/routes/albums/[albumId]/index.svelte b/web/src/routes/albums/[albumId]/index.svelte index 73d7b2d20f..7f1a2fd506 100644 --- a/web/src/routes/albums/[albumId]/index.svelte +++ b/web/src/routes/albums/[albumId]/index.svelte @@ -2,13 +2,15 @@ export const prerender = false; import type { Load } from '@sveltejs/kit'; - import { AlbumResponseDto, api } from '@api'; + import { AlbumResponseDto } from '@api'; - export const load: Load = async ({ params }) => { + export const load: Load = async ({ fetch, params }) => { try { const albumId = params['albumId']; - const { data: albumInfo } = await api.albumApi.getAlbumInfo(albumId); + const albumInfo = await fetch(`/data/album/get-album-info?albumId=${albumId}`).then((r) => + r.json() + ); return { status: 200, diff --git a/web/src/routes/albums/[albumId]/photos/[assetId].svelte b/web/src/routes/albums/[albumId]/photos/[assetId].svelte index 5a5db2e620..e646a19f55 100644 --- a/web/src/routes/albums/[albumId]/photos/[assetId].svelte +++ b/web/src/routes/albums/[albumId]/photos/[assetId].svelte @@ -1,12 +1,10 @@