diff --git a/backend/src/auth/guard/user.guard.ts b/backend/src/auth/guard/user.guard.ts index 94516953..32b1bf90 100644 --- a/backend/src/auth/guard/user.guard.ts +++ b/backend/src/auth/guard/user.guard.ts @@ -1,7 +1,6 @@ -import { Injectable, ExecutionContext, BadRequestException } from '@nestjs/common'; +import { Injectable, ExecutionContext } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { AuthGuard } from '@nestjs/passport'; -import { Request } from 'express'; import { Observable } from 'rxjs'; import { AppConfigService } from '../../config/app/configuration.service'; @@ -13,22 +12,6 @@ export class UserGuard extends AuthGuard('user') { } canActivate(context: ExecutionContext): boolean | Promise | Observable { - const skipUserGuard = this.reflector.get('skipUserGuard', context.getHandler()); - if (skipUserGuard) { - return true; - } - // 개발 환경에서는 토큰 검증을 하지 않음 - if (this.appConfigService.env === 'development') { - const request: Request = context.switchToHttp().getRequest(); - const userId = request.headers['x-my-id']; - if (userId === undefined) { - throw new BadRequestException('x-my-id is undefined'); - } - request.user = { - userId: +userId, - }; - return true; - } return super.canActivate(context); } } diff --git a/docker-compose.local.yml b/docker-compose.local.yml index bd37b4d9..a06dad41 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -4,7 +4,7 @@ services: image: postgres:15.3-alpine restart: always env_file: - - ./backend/.env + - ./backend/.env.local volumes: - db_data_local:/var/lib/postgresql/data expose: diff --git a/frontend/src/libs/api/client.ts b/frontend/src/libs/api/client.ts index d8fe6d38..7eff5f2e 100644 --- a/frontend/src/libs/api/client.ts +++ b/frontend/src/libs/api/client.ts @@ -2,9 +2,8 @@ import axios, { AxiosError, AxiosResponse } from 'axios'; import { getAccessToken } from './auth'; const createAxiosInstance = () => { - const isDev = import.meta.env.MODE === 'development'; const token = getAccessToken(); - const headers = isDev ? { 'x-my-id': token ?? '1' } : { Authorization: `Bearer ${token}` }; + const headers = { Authorization: `Bearer ${token}` }; return axios.create({ baseURL: import.meta.env.VITE_API_URL, headers, timeout: 100000, withCredentials: true }); }; diff --git a/frontend/src/libs/api/socket.ts b/frontend/src/libs/api/socket.ts index b3c4e9a9..5fc89e6d 100644 --- a/frontend/src/libs/api/socket.ts +++ b/frontend/src/libs/api/socket.ts @@ -2,22 +2,13 @@ import { io } from 'socket.io-client'; import { getAccessToken } from './auth'; const createSocketInstance = () => { - const isDev = import.meta.env.MODE === 'development'; const token = getAccessToken(); - if (isDev) { - return io(import.meta.env.VITE_BASE_URL, { - autoConnect: false, - extraHeaders: { 'x-my-id': token ?? '1' }, - withCredentials: true, - }); - } else { - return io(import.meta.env.VITE_BASE_URL, { - autoConnect: false, - auth: { token: `${token ?? ''}` }, - withCredentials: true, - }); - } + return io(import.meta.env.VITE_BASE_URL, { + autoConnect: false, + auth: { token: `${token ?? ''}` }, + withCredentials: true, + }); }; export const socket = createSocketInstance(); diff --git a/package.json b/package.json new file mode 100644 index 00000000..8119efb9 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "ghostpong", + "version": "1.0.0", + "scripts": { + "start": "docker-compose -f ./docker-compose.local.yml up", + "restart": "docker-compose -f ./docker-compose.local.yml up --build", + "stop": "docker-compose down" + }, + "author": "", + "license": "ISC" +}