我想要以下路线行为:
webapp/static/
中存在的任何路径都应路由到该文件/auth
或/api
开头的任何其他路径都应路由至webapp/static/pages/index.html
我有以下uWSGI配置:
[uwsgi]
http-socket = :$(PORT)
master = true
processes = 4
die-on-term = true
module = webapp:app
memory-report = true
;HSTS
route-host = ^localhost:(?:[0-9]+)$ goto:localhost
route-if-not = equal:${HTTP_X_FORWARDED_PROTO};https redirect-permanent:https://${HTTP_HOST}${REQUEST_URI}
route-if = equal:${HTTP_X_FORWARDED_PROTO};https addheader:Strict-Transport-Security: max-age=31536000; preload
route-label = localhost
check-static = %v/webapp/static/
route = ^(/?|/(?!(auth.*|api.*))(.*))$ static:%v/webapp/static/pages/index.html
问题是最终路由规则是否覆盖静态文件处理程序,即使我更改了它们的顺序..以前,我使用正则表达式^/?$
仅向/
发送请求到索引页面,它工作得很好,所以它必须与正则表达式的工作方式有关。
答案 0 :(得分:0)
可能在正则表达式之后评估静态规则。您使用的正则表达式也匹配/webapp/static
路径,因此我们也需要排除该路径。
尝试像这样修改正则表达式规则:
# I removed also unused matching groups and append '/' to the exclude path
route = ^(?:/?|/(?!(?:auth|api|webapp/static)/).*)$ static:%v/webapp/static/pages/index.html