用于 Angular 单页应用 (SPA) 的 Caddyfile
ng build 创建一个静态文件目录。由于 Angular 的工作方式,你需要重写每个不存在的 URL。例如,/patterns 需要重写为(但不重定向到)/
此 Caddyfile 从 /usr/share/caddy 静态提供文件并通过 try_files 执行重写:
Caddyfile
:80
root * /usr/share/caddy
file_server
try_files {path} /Check out similar posts by category:
Networking
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow