web-config修改

This commit is contained in:
2025-11-25 10:33:24 +08:00
parent 16232090d7
commit 61d63be941
2 changed files with 8 additions and 5 deletions

View File

@@ -60,15 +60,18 @@ const devConfig: AppRuntimeConfig = {
env: 'development', env: 'development',
api: { api: {
baseUrl: 'http://127.0.0.1:8081/schoolNewsServ', // 开发环境通过 Vite 代理转发到后端,避免浏览器直接跨域
// 实际请求路径示例:/api/schoolNewsServ/... → 由代理转发到 http://127.0.0.1:8081/schoolNewsServ/...
baseUrl: '/api/schoolNewsServ',
timeout: 30000 timeout: 30000
}, },
baseUrl: '/schoolNewsWeb/', baseUrl: '/schoolNewsWeb/',
file: { file: {
downloadUrl: 'http://127.0.0.1:8081/schoolNewsServ/file/download/', // 同样走代理,保持与 api.baseUrl 一致
uploadUrl: 'http://127.0.0.1:8081/schoolNewsServ/file/upload', downloadUrl: '/api/schoolNewsServ/file/download/',
uploadUrl: '/api/schoolNewsServ/file/upload',
maxSize: { maxSize: {
image: 5, image: 5,
video: 100, video: 100,
@@ -168,7 +171,7 @@ const getRuntimeConfig = (): AppRuntimeConfig => {
// 当前应用配置 // 当前应用配置
const config = getRuntimeConfig(); const config = getRuntimeConfig();
console.log('[配置] 当前配置', config);
// ============================================ // ============================================
// 导出配置(向后兼容) // 导出配置(向后兼容)
// ============================================ // ============================================

View File

@@ -63,7 +63,7 @@ export default defineConfig({
// 代理配置 // 代理配置
proxy: { proxy: {
'/api': { '/api': {
target: 'http://127.0.0.1:8081/schoolNewsServ', target: 'http://127.0.0.1:8081',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
configure: (proxy, options) => { configure: (proxy, options) => {