Skip to content

Commit 28cfa59

Browse files
committed
fix(backend): Cors access to localhost
1 parent 838fdac commit 28cfa59

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

apps/backend/src/plugins/welcome/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"author_url": "https://vitnode.com/",
1010
"support_url": "https://github.com/VitNode/vitnode/issues",
1111
"allow_default": true
12-
}
12+
}

packages/backend/src/main.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface Args {
1616
}
1717

1818
interface CorsOptionsMain extends Omit<CorsOptions, 'credentials'> {
19-
origin?: (RegExp | string)[];
19+
origin?: (RegExp | string)[] | string;
2020
}
2121

2222
export const nestjsMainApp = async (app: INestApplication, options?: Args) => {
@@ -28,9 +28,7 @@ export const nestjsMainApp = async (app: INestApplication, options?: Args) => {
2828
credentials: true,
2929
exposedHeaders: ['Content-Disposition'],
3030
origin: [
31-
process.env.NODE_ENV === 'development'
32-
? '*'
33-
: (process.env.NEXT_PUBLIC_FRONTEND_URL ?? 'http://localhost:3000'),
31+
process.env.NEXT_PUBLIC_FRONTEND_URL ?? 'http://localhost:3000',
3432
...(options?.cors?.origin ?? []),
3533
],
3634
});
@@ -83,7 +81,7 @@ export const nestjsMainApp = async (app: INestApplication, options?: Args) => {
8381
});
8482
};
8583

86-
export const nestFactoryOptions: NestApplicationOptions = {
84+
export const nestFactoryOptions: Omit<NestApplicationOptions, 'cors'> = {
8785
rawBody: true,
8886
bodyParser: true,
8987
};

pnpm-lock.yaml

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)