Skip to content

Commit 176e618

Browse files
small test
1 parent 0a74ffb commit 176e618

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/main.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,7 @@ import { LogsService } from './common/logging/logs.service';
1111

1212
async function bootstrap() {
1313
const app = await NestFactory.create<NestExpressApplication>(AppModule);
14-
app.enableCors({
15-
origin: (origin, callback) => {
16-
if (!origin) return callback(null, true);
17-
if (origin === 'http://localhost:3000') return callback(null, true);
18-
if (/^https:\/\/[a-z0-9-]+\.preview\.codesignal\.dev$/.test(origin)) {
19-
return callback(null, true);
20-
}
21-
return callback(new Error(`CORS blocked for origin: ${origin}`), false);
22-
},
23-
credentials: true,
24-
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
25-
allowedHeaders: ['Content-Type', 'Authorization', 'Accept'], // ✅ explicit list
26-
preflightContinue: false,
27-
optionsSuccessStatus: 204,
28-
});
14+
app.enableCors();
2915

3016
app.useGlobalPipes(
3117
new ValidationPipe({

src/users/users.controller.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import { Controller, Get, Post, Body, Patch, Param, Delete, ParseIntPipe, UseGuards } from '@nestjs/common';
1+
import {
2+
Controller,
3+
Get,
4+
Post,
5+
Body,
6+
Patch,
7+
Param,
8+
Delete,
9+
ParseIntPipe,
10+
UseGuards,
11+
} from '@nestjs/common';
212
import { UsersService } from './users.service';
313
import { CreateUserDto } from './dto/create-user.dto';
414
import { UpdateUserDto } from './dto/update-user.dto';
515
import { Roles } from '../common/decorators/roles.decorator';
616
import { RolesGuard } from '../common/guards/roles.guard';
717
import { Public } from '../common/decorators/public.decorator';
818

9-
@Controller('users')
19+
@Controller('api/users')
1020
export class UsersController {
1121
constructor(private readonly usersService: UsersService) {}
1222

@@ -30,7 +40,10 @@ export class UsersController {
3040
@Patch(':id')
3141
@UseGuards(RolesGuard)
3242
@Roles('admin')
33-
update(@Param('id', ParseIntPipe) id: number, @Body() updateUserDto: UpdateUserDto) {
43+
update(
44+
@Param('id', ParseIntPipe) id: number,
45+
@Body() updateUserDto: UpdateUserDto,
46+
) {
3447
return this.usersService.update(id, updateUserDto);
3548
}
3649

@@ -51,4 +64,3 @@ export class UsersController {
5164
return this.usersService.getStats(id);
5265
}
5366
}
54-

0 commit comments

Comments
 (0)