33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
# Apache .htaccess 配置文件
|
||
# 放置在 dist 目录下
|
||
# 解决 Vue SPA 应用的路由问题
|
||
|
||
<IfModule mod_rewrite.c>
|
||
RewriteEngine On
|
||
|
||
# 处理预检请求
|
||
RewriteCond %{REQUEST_METHOD} OPTIONS
|
||
RewriteRule ^(.*)$ $1 [R=200,L]
|
||
|
||
# 静态资源直接访问
|
||
RewriteCond %{REQUEST_FILENAME} -f
|
||
RewriteRule ^ - [L]
|
||
|
||
# API请求代理到后端(需要配置虚拟主机)
|
||
RewriteCond %{REQUEST_URI} ^/api/
|
||
RewriteRule ^api/(.*)$ http://192.140.164.137:18080/$1 [P,L]
|
||
|
||
# SPA路由回退到index.html
|
||
RewriteCond %{REQUEST_FILENAME} !-f
|
||
RewriteCond %{REQUEST_FILENAME} !-d
|
||
RewriteRule . /index.html [L]
|
||
</IfModule>
|
||
|
||
# CORS 头部设置
|
||
<IfModule mod_headers.c>
|
||
Header always set Access-Control-Allow-Origin "*"
|
||
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||
Header always set Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"
|
||
Header always set Access-Control-Max-Age "1728000"
|
||
</IfModule>
|