mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Add AUTH_SECURE_COOKIES config and improve CORS origin handling
This commit is contained in:
1 parent
10fd14ac4d
commit
31d8d53f7c
3 files changed
+8
-2
No files matched your search
@@ -44,7 +44,12 @@ const DB_PATH = getDatabasePath()
|
||||
const app = new Hono()
|
||||
|
||||
app.use('/*', cors({
|
||||
origin: (origin) => origin || '*',
|
||||
origin: (origin) => {
|
||||
const trustedOrigins = ENV.AUTH.TRUSTED_ORIGINS.split(',').map(o => o.trim())
|
||||
if (!origin) return trustedOrigins[0]
|
||||
if (trustedOrigins.includes(origin)) return origin
|
||||
return trustedOrigins[0]
|
||||
},
|
||||
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowHeaders: ['Content-Type', 'Authorization'],
|
||||
credentials: true,
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ services:
|
||||
- "5102:5102"
|
||||
- "5103:5103"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- NODE_ENV=${NODE_ENV:-production}
|
||||
- HOST=0.0.0.0
|
||||
- PORT=5003
|
||||
- OPENCODE_SERVER_PORT=5551
|
||||
|
||||
@@ -94,6 +94,7 @@ export const ENV = {
|
||||
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
|
||||
ADMIN_PASSWORD: process.env.ADMIN_PASSWORD,
|
||||
ADMIN_PASSWORD_RESET: getEnvBoolean('ADMIN_PASSWORD_RESET', false),
|
||||
SECURE_COOKIES: getEnvBoolean('AUTH_SECURE_COOKIES', process.env.NODE_ENV === 'production'),
|
||||
GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID,
|
||||
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
|
||||
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
||||
|
||||
Reference in new issue
Block a user