feat: added secure cookie env

Signed-off-by: Varun Raj <mailme@varunraj.in>
This commit is contained in:
Varun Raj committed 2024-09-07 19:37:18 +05:30
1 parent bcb12473e0
commit 23c341cba5
4 files changed
+7 -2

No files matched your search

+3
View File
@@ -5,3 +5,6 @@ DB_PASSWORD="" # Postgres Database Password
DB_HOST="" # Postgres Host (IP address or hostname of the database) DB_HOST="" # Postgres Host (IP address or hostname of the database)
DB_PORT="" # Postgres Port number (Default: 5432) DB_PORT="" # Postgres Port number (Default: 5432)
DB_DATABASE_NAME="" # Name of the database DB_DATABASE_NAME="" # Name of the database
# Additional configuration
SECURE_COOKIE=false # Set to true to enable secure cookies
+1
View File
@@ -41,6 +41,7 @@ IMMICH_URL = "http://local-ip-of-immich:port" # Your immich instace ip address a
EXTERNAL_IMMICH_URL = "https://external-address" # External address of immich EXTERNAL_IMMICH_URL = "https://external-address" # External address of immich
``` ```
Refer here for obtaining Immich API Key: https://immich.app/docs/features/command-line-interface#obtain-the-api-key Refer here for obtaining Immich API Key: https://immich.app/docs/features/command-line-interface#obtain-the-api-key
#### Method 2 - Portainer #### Method 2 - Portainer
If you're using portainer, run the docker using `docker run` and add the power tools to the same network as immich. If you're using portainer, run the docker using `docker run` and add the power tools to the same network as immich.
+1
View File
@@ -4,6 +4,7 @@ export const ENV = {
IMMICH_API_KEY: process.env.IMMICH_API_KEY as string, IMMICH_API_KEY: process.env.IMMICH_API_KEY as string,
DATABASE_URL: (process.env.DATABASE_URL || `postgresql://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${(process.env.DB_HOST || 'immich_postgres')}:${(process.env.DB_PORT || '5432')}/${process.env.DB_DATABASE_NAME}`), DATABASE_URL: (process.env.DATABASE_URL || `postgresql://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${(process.env.DB_HOST || 'immich_postgres')}:${(process.env.DB_PORT || '5432')}/${process.env.DB_DATABASE_NAME}`),
JWT_SECRET: process.env.JWT_SECRET as string, JWT_SECRET: process.env.JWT_SECRET as string,
SECURE_COOKIE: process.env.SECURE_COOKIE === 'true',
}; };
+2 -2
View File
@@ -1,3 +1,4 @@
import { ENV } from '@/config/environment'
import type { CookieSerializeOptions } from 'cookie' import type { CookieSerializeOptions } from 'cookie'
import cookie from 'cookie' import cookie from 'cookie'
import type { IncomingMessage } from 'http' import type { IncomingMessage } from 'http'
@@ -22,8 +23,7 @@ export const serializeCookie = (
return cookie.serialize(name, String(value), { return cookie.serialize(name, String(value), {
httpOnly: true, httpOnly: true,
maxAge: 60 * 60 * 24 * 7, maxAge: 60 * 60 * 24 * 7,
sameSite: process.env.NODE_ENV === 'production' ? 'none' : 'lax', secure: ENV.SECURE_COOKIE,
secure: process.env.NODE_ENV === 'production',
path: '/', path: '/',
...options, ...options,
}) })