update: 移除api的特殊处理,使用配置项实现

This commit is contained in:
Kerwin
2025-08-18 19:40:10 +08:00
parent c053a17131
commit eeca85942f
2 changed files with 8 additions and 5 deletions

3
web/components.d.ts vendored
View File

@@ -23,11 +23,9 @@ declare module 'vue' {
NEmpty: typeof import('naive-ui')['NEmpty'] NEmpty: typeof import('naive-ui')['NEmpty']
NForm: typeof import('naive-ui')['NForm'] NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem'] NFormItem: typeof import('naive-ui')['NFormItem']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage'] NImage: typeof import('naive-ui')['NImage']
NImageGroup: typeof import('naive-ui')['NImageGroup'] NImageGroup: typeof import('naive-ui')['NImageGroup']
NInput: typeof import('naive-ui')['NInput'] NInput: typeof import('naive-ui')['NInput']
NInputGroup: typeof import('naive-ui')['NInputGroup']
NList: typeof import('naive-ui')['NList'] NList: typeof import('naive-ui')['NList']
NListItem: typeof import('naive-ui')['NListItem'] NListItem: typeof import('naive-ui')['NListItem']
NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NMessageProvider: typeof import('naive-ui')['NMessageProvider']
@@ -41,7 +39,6 @@ declare module 'vue' {
NSpace: typeof import('naive-ui')['NSpace'] NSpace: typeof import('naive-ui')['NSpace']
NSpin: typeof import('naive-ui')['NSpin'] NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch'] NSwitch: typeof import('naive-ui')['NSwitch']
NTable: typeof import('naive-ui')['NTable']
NTabPane: typeof import('naive-ui')['NTabPane'] NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs'] NTabs: typeof import('naive-ui')['NTabs']
NTag: typeof import('naive-ui')['NTag'] NTag: typeof import('naive-ui')['NTag']

View File

@@ -30,6 +30,12 @@ export default defineNuxtConfig({
}, },
server: { server: {
proxy: { proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
secure: false,
rewrite: (path) => path
},
'/uploads': { '/uploads': {
target: 'http://localhost:8080', target: 'http://localhost:8080',
changeOrigin: true, changeOrigin: true,
@@ -62,9 +68,9 @@ export default defineNuxtConfig({
runtimeConfig: { runtimeConfig: {
public: { public: {
// 开发环境:直接访问后端,生产环境:通过 Nginx 反代 // 开发环境:直接访问后端,生产环境:通过 Nginx 反代
apiBase: process.env.NODE_ENV === 'production' ? '/api' : 'http://localhost:8080/api', apiBase: process.env.NODE_ENV === 'production' ? '/api' : '/api',
// 服务端:开发环境直接访问,生产环境容器内访问 // 服务端:开发环境直接访问,生产环境容器内访问
apiServer: process.env.NODE_ENV === 'production' ? 'http://backend:8080/api' : 'http://localhost:8080/api' apiServer: process.env.NODE_ENV === 'production' ? 'http://backend:8080/api' : '/api'
} }
}, },
build: { build: {