Skip to content

Commit

Permalink
public paths på kodeverk
Browse files Browse the repository at this point in the history
  • Loading branch information
sindredl committed Aug 9, 2024
1 parent 9c06f8e commit c823e5d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/src/proxy/api-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { createProxyMiddleware } from 'http-proxy-middleware';
import { ParsedQs } from 'qs';
import { requestOboToken } from '../auth';

const publicPaths = [
'/tiltaksgjennomforing/api/kodeverk',
'/tiltaksgjennomforing/api/kodeverk/statuser',
'/tiltaksgjennomforing/api/kodeverk/tiltakstyper',
];

const tokenxSetup = (app: Express): void => {
console.log('api-proxy setup for tokenx');
setup(app, process.env.API_AUDIENCE!);
Expand All @@ -22,10 +28,7 @@ const setup = (app: Express, audience: string) => {

app.use('/tiltaksgjennomforing/api', (req, res, next) => {
console.log('apiProxy /tiltaksgjennomforing/api');
if (req.path === '/tiltaksgjennomforing/api/kodeverk') {
next();
}
if (!req.headers['authorization']) {
if (!req.headers['authorization'] && !publicPaths.includes(req.path)) {
res.status(401).send();
} else {
next();
Expand Down

0 comments on commit c823e5d

Please sign in to comment.