47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
'/api/semrush': {
|
|
target: 'https://api.semrush.com',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api\/semrush/, ''),
|
|
configure: (proxy, options) => {
|
|
proxy.on('proxyReq', (proxyReq, req, res) => {
|
|
// Add CORS headers to the request
|
|
proxyReq.setHeader('Origin', 'https://api.semrush.com');
|
|
});
|
|
proxy.on('proxyRes', (proxyRes, req, res) => {
|
|
// Add CORS headers to the response
|
|
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
|
|
proxyRes.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS';
|
|
proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization';
|
|
});
|
|
}
|
|
},
|
|
'/api/analytics': {
|
|
target: 'https://api.semrush.com',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api\/analytics/, '/analytics'),
|
|
configure: (proxy, options) => {
|
|
proxy.on('proxyReq', (proxyReq, req, res) => {
|
|
// Add CORS headers to the request
|
|
proxyReq.setHeader('Origin', 'https://api.semrush.com');
|
|
});
|
|
proxy.on('proxyRes', (proxyRes, req, res) => {
|
|
// Add CORS headers to the response
|
|
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
|
|
proxyRes.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS';
|
|
proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization';
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|