fix(vite): 使用代理,以解决跨域问题

This commit is contained in:
SvenFE
2025-08-25 11:27:38 +08:00
parent 9f7ece51fe
commit f436ccd087
2 changed files with 10 additions and 3 deletions

View File

@@ -1,3 +1,2 @@
VITE_CLERK_PUBLISHABLE_KEY=
VITE_STEPFUN_ENDPOINT=
VITE_STEPFUN_ENDPOINT=/proxy
VITE_STEPFUN_API_KEY=

View File

@@ -4,7 +4,6 @@ import react from '@vitejs/plugin-react-swc'
import tailwindcss from '@tailwindcss/vite'
import { tanstackRouter } from '@tanstack/router-plugin/vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [
tanstackRouter({
@@ -19,4 +18,13 @@ export default defineConfig({
'@': path.resolve(__dirname, './src'),
},
},
server: {
proxy: {
'/proxy': {
target: 'https://api.stepfun.com/v1',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy/, ''),
},
},
},
})