Skip to content

Commit

Permalink
adding cors
Browse files Browse the repository at this point in the history
  • Loading branch information
mtguerson committed Apr 10, 2024
1 parent a206fe9 commit 27d6e20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"private": true,
"license": "UNLICENSED",
"files.eol": "\n",

"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Expand All @@ -31,6 +30,7 @@
"bcryptjs": "^2.4.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"prisma": "^5.11.0",
"reflect-metadata": "^0.2.0",
Expand Down
9 changes: 8 additions & 1 deletion api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { CategoriesModule } from './modules/categories/categories.module';
import { BankAccountsModule } from './modules/bank-accounts/bank-accounts.module';
import { TransactionsModule } from './modules/transactions/transactions.module';
@Module({
imports: [UsersModule, DatabaseModule, AuthModule, CategoriesModule, BankAccountsModule, TransactionsModule],
imports: [
UsersModule,
DatabaseModule,
AuthModule,
CategoriesModule,
BankAccountsModule,
TransactionsModule,
],
controllers: [],
providers: [
{
Expand Down
3 changes: 3 additions & 0 deletions api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
const cors = require('cors');
const app = await NestFactory.create(AppModule);

app.use(cors({ origin: 'http://localhost:5173' }));

app.useGlobalPipes(new ValidationPipe());

await app.listen(3000);
Expand Down
2 changes: 1 addition & 1 deletion api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ core-util-is@^1.0.3, core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==

cors@2.8.5:
cors@2.8.5, cors@^2.8.5:
version "2.8.5"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
Expand Down

0 comments on commit 27d6e20

Please sign in to comment.