Skip to content

Commit

Permalink
Merge pull request #222 from read-a-perfume/feature/opt
Browse files Browse the repository at this point in the history
fix: 로그인 CORS 이슈 => SSL 인증제거
  • Loading branch information
gn753 authored Apr 6, 2024
2 parents 22aac0d + 2ff8f81 commit 9192244
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_API_KEY= "/api"
VITE_API_KEY= "/api"
VITE_API_URL= "http://ec2-43-203-196-14.ap-northeast-2.compute.amazonaws.com/api/v1"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ node_modules
dist
dist-ssr
*.local

.env.development
# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
1 change: 0 additions & 1 deletion src/vite-env.d.ts

This file was deleted.

10 changes: 10 additions & 0 deletions vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_URL: string
readonly VITE_API_KEY: string
// 다른 환경 변수들에 대한 타입 정의...
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
41 changes: 19 additions & 22 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import tsconfigPaths from 'vite-tsconfig-paths'
import {defineConfig} from 'vite'
import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react'
import checker from 'vite-plugin-checker'
// import envCompatible from "vite-plugin-env-compatible";

export default defineConfig(({command, mode}) => {
if (command === 'serve' && mode === 'development') {
process.env = {...process.env, ...loadEnv(mode, process.cwd())}
return {
env: env,
plugins: plugins,
server: derServer,
server: {
open: '/',
proxy: {
// 경로가 "/api" 로 시작하는 요청을 대상으로 proxy 설정
'/api': {
// 요청 전달 대상 서버 주소 설정
target: process.env.VITE_API_URL,
// 요청 헤더 host 필드 값을 대상 서버의 호스트 이름으로 변경
changeOrigin: true,
// 요청 경로에서 '/api' 제거
rewrite: path => path.replace(/^\/api/, ''),
// SSL 인증서 검증 무시
secure: false,
},
},
},
}
} else {
// command === 'build'
Expand All @@ -24,26 +40,7 @@ export default defineConfig(({command, mode}) => {
const env = {
// `.env` 파일의 모든 환경변수를 읽어옵니다.
// `.env` 파일의 환경변수를 선택적으로 읽어오려면 `keys` 옵션을 사용합니다.
keys: ['VITE_API_KEY'],
}

const derServer = {
open: '/',
proxy: {
// 경로가 "/api" 로 시작하는 요청을 대상으로 proxy 설정
'/api': {
// 요청 전달 대상 서버 주소 설정
target: 'https://perfume.app.cd80.run/api/v1',
// 요청 헤더 host 필드 값을 대상 서버의 호스트 이름으로 변경
changeOrigin: true,
// 요청 경로에서 '/api' 제거
rewrite: path => path.replace(/^\/api/, ''),
// SSL 인증서 검증 무시
secure: true,
// WebSocket 프로토콜 사용
ws: true,
},
},
keys: ['VITE_API_URL', 'VITE_API_KEY'],
}

const plugins = [
Expand Down

0 comments on commit 9192244

Please sign in to comment.