Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions __tests__/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('setting of response header `Access-Control-Allow-Origin`', () => {
'http://localhost:3000',
'http://localhost:3001',
'https://frontend-7md9ymhyw-serlo.vercel.app',
'https://chancencampus.org',
]

describe('when we are in the staging environment, the same value is sent back in `Access-Control-Allow-Origin`', () => {
Expand All @@ -94,7 +95,7 @@ describe('setting of response header `Access-Control-Allow-Origin`', () => {
})
})

describe('when we are in the production environment, the current domain is sent back in `Access-Control-Allow-Origin`', () => {
describe('when we are in the production environment, the current domain or chancencampus.org is sent back in `Access-Control-Allow-Origin`', () => {
test.each(domains)('when `Origin` is `%s`', async (origin) => {
const env = currentTestEnvironmentWhen(
(conf) => conf.ENVIRONMENT === 'production',
Expand All @@ -103,9 +104,15 @@ describe('setting of response header `Access-Control-Allow-Origin`', () => {

const response = await fetchApi({ headers: { Origin: origin } }, env)

expect(response.headers.get('Access-Control-Allow-Origin')).toBe(
`https://${env.getDomain()}`,
)
if (origin == 'https://chancencampus.org') {
expect(response.headers.get('Access-Control-Allow-Origin')).toBe(
'https://chancencampus.org',
)
} else {
expect(response.headers.get('Access-Control-Allow-Origin')).toBe(
`https://${env.getDomain()}`,
)
}
})
})
})
Expand Down
3 changes: 2 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function getAllowedOrigin(requestOrigin: string | null, env: CFEnvironment) {
url.port === '8000' ||
url.port === '8080')) ||
url.hostname.includes('-serlo.vercel.app'))) ||
url.hostname.includes('.adornis.de')
url.hostname.includes('.adornis.de') ||
url.domain === 'chancencampus.org'
) {
return requestOrigin
}
Expand Down