initial commit
This commit is contained in:
33
vite.config.js
Normal file
33
vite.config.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// Dev mode: proxy /api/* to api.workolik.com and inject x-hasura-admin-secret
|
||||
// server-side so the secret never reaches the browser.
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
const secret = (env.HASURA_ADMIN_SECRET || '').trim()
|
||||
|
||||
if (!secret) {
|
||||
console.warn('[xpress-docs] HASURA_ADMIN_SECRET is not set in .env.local; proxied requests will hit the API without auth.')
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port: 5173,
|
||||
open: true,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'https://api.workolik.com',
|
||||
changeOrigin: true,
|
||||
secure: true,
|
||||
configure: (proxy) => {
|
||||
proxy.on('proxyReq', (proxyReq) => {
|
||||
if (secret) proxyReq.setHeader('x-hasura-admin-secret', secret)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user