Skip to content

Commit

Permalink
🛂 Config for å tillate spørringer fra mikrofrontend
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrognes authored Feb 15, 2024
2 parents ecd4c79 + 8d2c048 commit a44dc12
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pages/api/soknader/soknaderInnsending.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { beskyttetApi, getAccessTokenFromRequest } from '@navikt/aap-felles-utils';
import { getSøknaderInnsending } from 'pages/api/soknader/soknader';

const allowedOrigins = [
'https://www.intern.dev.nav.no',
'https://aap-mine-aap.intern.dev.nav.no',
'https://www.nav.no',
];

const handler = beskyttetApi(async (req, res) => {
const accessToken = getAccessTokenFromRequest(req);
const søknader = await getSøknaderInnsending(accessToken);
if (req.headers.origin) {
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Access-Control-Allow-Origin', allowedOrigins.includes(req.headers.origin) ? req.headers.origin : '');
res.setHeader('Access-Control-Allow-Methods', 'GET,OPTIONS,PATCH,DELETE,POST,PUT');
res.setHeader(
'Access-Control-Allow-Headers',
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version'
);
}

res.status(200).json(søknader);
});

Expand Down

0 comments on commit a44dc12

Please sign in to comment.