【发布时间】:2019-08-10 18:46:40
【问题描述】:
我正在尝试在应用引擎中部署 Angular 7 应用
使用 ng deploy --prod 创建部署。现在使用 app.yaml 部署生成的dist。
app.yaml 的内容
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist
- url: /\w{3,}-?[^.\s]\w*
static_files: dist/index.html
upload: dist/index.html
如果 URL 未更改,即 domain.com,则此方法非常有效,但当 url 更改为 domain.com/login 或 domain.com/profile 时,它会生成 404 错误
Error: Not Found
The requested URL /admin-dashboard was not found on this server.
为了解决重定向问题,我在 app.yaml 中添加了 url 模式以匹配任何 url 并转发到 dist/index.html
- url: /\w{3,}-?[^.\s]\w*
static_files: dist/index.html
upload: dist/index.html
但这无济于事。我完全被困住了。请任何指针 @Christopher Peisert 非常感谢您的指点。这是适用于所有类型 URL 模式的最终 app.yaml
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /\w+$
static_files: dist/index.html
upload: dist/index.html
- url: /(\w+-\w+)$
static_files: dist/index.html
upload: dist/index.html
- url: /(.*)$
static_files: dist/\1
upload: dist/(.*)
【问题讨论】: