Skip to content

Commit

Permalink
domains
Browse files Browse the repository at this point in the history
  • Loading branch information
wslyvh committed Oct 30, 2024
1 parent 96db7fa commit fe7c58b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions devcon-api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ app.use(logHandler)

const ALLOWED_ORIGINS = [
'https://api.devcon.org',
'https://app.devcon.org',
'https://archive.devcon.org',
'https://devcon.org',
'https://dev--devcon-app.netlify.app',
'http://localhost:3000', // Local development
'http://localhost:3000',
]

app.use(
cors({
origin: (origin, callback) => {
// Allow requests with no origin (like mobile apps, curl, etc)
if (!origin) {
console.log('No origin')
// Allow requests with no origin (like mobile apps, curl, etc)
return callback(null, true)
}

if (ALLOWED_ORIGINS.indexOf(origin) !== -1 || SERVER_CONFIG.NODE_ENV !== 'production') {
callback(null, true)
} else {
console.warn('Blocked by CORS:', origin)
console.warn('BLOCKED by CORS:', origin)
callback(null, true) // Still allow it for now
}
},
Expand All @@ -60,10 +61,7 @@ const sessionConfig: SessionOptions = {
sameSite: 'none',
secure: SERVER_CONFIG.NODE_ENV === 'production',
path: '/',
domain:
SERVER_CONFIG.NODE_ENV === 'production'
? 'devcon.org' // Main domain
: undefined,
domain: SERVER_CONFIG.NODE_ENV === 'production' ? '.devcon.org' : undefined,
},
resave: false,
saveUninitialized: false,
Expand Down

0 comments on commit fe7c58b

Please sign in to comment.