Skip to content

Commit

Permalink
set COI headers based on vscode-coi query (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken authored Jul 20, 2022
1 parent bc48dc9 commit cd5eb1c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ export default async function createApp(config: IConfig): Promise<Koa> {
return next();
});

// COI
app.use((ctx, next) => {
const value = ctx.query['vscode-coi'];
if (value === '1') {
ctx.set('Cross-Origin-Opener-Policy', 'same-origin');
} else if (value === '2') {
ctx.set('Cross-Origin-Embedder-Policy', 'require-corp');
} else if (value === '3' || value === '') {
ctx.set('Cross-Origin-Opener-Policy', 'same-origin');
ctx.set('Cross-Origin-Embedder-Policy', 'require-corp');
}
return next()
})

// shift the line numbers of source maps in extensions by 2 as the content is wrapped by an anonymous function
app.use(async (ctx, next) => {
await next();
Expand Down Expand Up @@ -84,4 +98,3 @@ export default async function createApp(config: IConfig): Promise<Koa> {

return app;
}

0 comments on commit cd5eb1c

Please sign in to comment.