Browse Source

update back

mrs4z 3 years ago
parent
commit
b5053a72a4
3 changed files with 12 additions and 2 deletions
  1. 4 0
      config.json
  2. 1 1
      src/entities/user.entity.ts
  3. 7 1
      src/main.ts

+ 4 - 0
config.json

@@ -1,3 +1,7 @@
 {
+  "cors": [
+    "http://localhost:8080"
+  ],
+  "port": 3001,
   "jwt": "sadpnq0r03fDFLKSHD9h2810fosdfh03223"
 }

+ 1 - 1
src/entities/user.entity.ts

@@ -6,7 +6,7 @@ import { classToPlain, Exclude } from 'class-transformer';
 @Entity('user')
 export class UserEntity extends BaseEntity {
   @ApiProperty()
-  @PrimaryGeneratedColumn()
+  @PrimaryGeneratedColumn("uuid")
   id: number;
 
   @ApiProperty()

+ 7 - 1
src/main.ts

@@ -3,12 +3,18 @@ import { AppModule } from './app.module';
 import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
 import { ValidationPipe } from '@nestjs/common';
 import { ErrorsInterceptor } from './interceptor/errors.interceptor';
+import mainConfig from 'config.json';
 
 async function bootstrap() {
   const app = await NestFactory.create(AppModule);
   app.useGlobalPipes(new ValidationPipe());
   app.useGlobalInterceptors(new ErrorsInterceptor());
   app.setGlobalPrefix('api');
+  app.enableCors({
+    origin: mainConfig.cors,
+    credentials: true,
+    exposedHeaders: ['set-cookie'],
+  });
 
   // SWAGGER
   const config = new DocumentBuilder()
@@ -19,6 +25,6 @@ async function bootstrap() {
   const document = SwaggerModule.createDocument(app, config);
   SwaggerModule.setup('api', app, document);
 
-  await app.listen(3000);
+  await app.listen(mainConfig.port);
 }
 bootstrap();