AppEngine app.yaml config for single page apps

﹥>﹥吖頭↗ 提交于 2019-12-05 18:40:30

Ah yes, I had the same problem. Here's the app.yaml that I'm using for an Angular2 app on Appengine:

runtime: python27
api_version: 1
threadsafe: true

handlers:

- url: /api/.*
  script: main.app

# All files that can be compiled in angular. Luckily, they all have suffixes.
- url: /(.*\.(css|eot|gz|html|ico|js|map|png|svg|ttf|woff|woff2))
  static_files: ../client/dist/\1
  upload: ../client/dist/(.*\.(css|eot|gz|html|ico|js|map|png|svg|ttf|woff|woff2))

# Site root, plus anything else, like deep urls
# Make this be secure, otherwise oauth redirect won't work if they want to us with http://
- url: /.*
  static_files: ../client/dist/index.html
  upload: ../client/dist/index.html
  secure: always
  expiration: "15m"

libraries:
- name: webapp2
  version: "2.5.2"

To handle deep links, you need a catch-all rule at the end to always serve index.html . However, before that, you need a rule which maps all your static content, I'm doing mine by the presence of a suffix, but another way you could do it is by specifically naming all the files and directories that are your static assets.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!