Commit f08c14e0 by 周田

feat:前后端分离(方便调试)

parent 338a39bf
...@@ -25,8 +25,16 @@ export default defineConfig({ ...@@ -25,8 +25,16 @@ export default defineConfig({
vue(), vue(),
UnoCSS() UnoCSS()
], ],
base: './', // base: './',
server: { server: {
host: '0.0.0.0', host: '0.0.0.0',
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8000/',
changeOrigin: true
} }
}
},
}) })
...@@ -44,6 +44,7 @@ INSTALLED_APPS = [ ...@@ -44,6 +44,7 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'corsheaders',
'rest_framework', 'rest_framework',
'drf_yasg', 'drf_yasg',
] ]
...@@ -163,3 +164,18 @@ CHANNEL_LAYERS = { ...@@ -163,3 +164,18 @@ CHANNEL_LAYERS = {
# }, # },
# }, # },
} }
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_HEADERS = [
'x-requested-with',
'content-type',
'accept',
'origin',
'authorization',
'x-csrftoken',
'token'
]
CORS_ALLOWED_ORIGINS = [
"http://127.0.0.1:5173", # 您的前端应用地址
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment