Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REV-376/api key 은닉 #106

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apis/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios'
import { TOKEN_KEY } from '@/constants'

const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_KEY,
baseURL: '/api',
})

apiClient.interceptors.request.use(
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"include": ["src","src/*"],
"references": [{ "path": "./tsconfig.node.json" }]
}
47 changes: 30 additions & 17 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import path from 'path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import svgr from 'vite-plugin-svgr'

export default defineConfig({
plugins: [react(), svgr()],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
// 환경 변수 로드
export default ({ mode }) => {
const env = { ...process.env, ...loadEnv(mode, process.cwd()) }

build: {
rollupOptions: {
external: (id) => {
if (id.includes('/node_modules/@mswjs')) {
return true
}
if (id.includes('/src/mocks')) {
return true
}
return defineConfig({
plugins: [react(), svgr()],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
build: {
rollupOptions: {
external: (id) => {
if (id.includes('/node_modules/@mswjs')) {
return true
}
if (id.includes('/src/mocks')) {
return true
}
},
},
},
server: {
proxy: {
'/api': {
target: env.VITE_API_KEY,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
},
})
})
}
Loading