77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
import path from 'path';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'mask-icon.svg'],
|
|
manifest: {
|
|
name: 'PWA React App',
|
|
short_name: 'PWA App',
|
|
description: 'Production-ready Progressive Web App',
|
|
theme_color: '#ffffff',
|
|
background_color: '#ffffff',
|
|
display: 'standalone',
|
|
orientation: 'portrait',
|
|
scope: '/',
|
|
start_url: '/',
|
|
icons: [
|
|
{
|
|
src: 'pwa-192x192.png',
|
|
sizes: '192x192',
|
|
type: 'image/png'
|
|
},
|
|
{
|
|
src: 'pwa-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png'
|
|
},
|
|
{
|
|
src: 'pwa-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
purpose: 'any maskable'
|
|
}
|
|
]
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}']
|
|
}
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src')
|
|
}
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api/n8n': {
|
|
target: 'https://nn.feep.ir',
|
|
changeOrigin: true,
|
|
rewrite: (path) => {
|
|
// تبدیل /api/n8n/webhook/... به /webhook/...
|
|
const rewritten = path.replace(/^\/api\/n8n/, '');
|
|
console.log(`[Proxy] Rewriting: ${path} -> ${rewritten}`);
|
|
return rewritten;
|
|
},
|
|
secure: true,
|
|
configure: (proxy, _options) => {
|
|
proxy.on('error', (err, _req, res) => {
|
|
console.log('[Proxy] Error:', err);
|
|
});
|
|
proxy.on('proxyReq', (proxyReq, req, _res) => {
|
|
console.log('[Proxy] Request:', req.method, req.url, '->', proxyReq.path);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|