- Implement OAuth 2.0 and PAT authentication methods - Add user management, roles, and profile functionality - Add database migrations and admin user scripts - Update services for authentication and user settings - Add protected routes and permission hooks - Update documentation for authentication and database access
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3001',
|
|
changeOrigin: true,
|
|
// Ensure cookies are forwarded correctly
|
|
configure: (proxy, _options) => {
|
|
proxy.on('proxyRes', (proxyRes, req, res) => {
|
|
// Rewrite Set-Cookie headers to work with the proxy
|
|
// Change domain from backend (localhost:3001) to frontend (localhost:5173)
|
|
const setCookieHeaders = proxyRes.headers['set-cookie'];
|
|
if (setCookieHeaders) {
|
|
const rewritten = Array.isArray(setCookieHeaders)
|
|
? setCookieHeaders.map(cookie => {
|
|
// Remove domain attribute or rewrite it to work with proxy
|
|
return cookie
|
|
.replace(/;\s*domain=[^;]+/gi, '') // Remove domain
|
|
.replace(/;\s*secure/gi, ''); // Remove secure in dev (if needed)
|
|
})
|
|
: [setCookieHeaders].map(cookie => {
|
|
return cookie
|
|
.replace(/;\s*domain=[^;]+/gi, '')
|
|
.replace(/;\s*secure/gi, '');
|
|
});
|
|
proxyRes.headers['set-cookie'] = rewritten;
|
|
console.log('[Vite Proxy] Rewritten Set-Cookie headers:', rewritten);
|
|
}
|
|
});
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|