【问题标题】:Multi-page URL Fallback (index.html & subpage.html)多页 URL 后备 (index.html & subpage.html)
【发布时间】:2018-09-10 18:55:43
【问题描述】:

我正在尝试使用 google apps python 引擎部署一个多页的 Vue.js 应用程序。

为了让 Vue.js 应用程序正常工作,我需要所有 URL 都回退,以便 vue javascript 路由器可以接管。

Index.html 链接

/foo

/条

/foo/bar

Subpage.html 链接

/子页面/foo

/子页面/栏

/subpage/foo/bar

在我当前的配置中,如果我从索引中删除通配符,则可以访问子页面,但索引链接不再起作用。是否有可能实现多个后备,首先是'/',其次是'/subpage/'?

我已经包含了我的 app.yaml,在我看来它应该可以按书面形式工作,但不能。

runtime: python27
api_version: 1
threadsafe: true

handlers:
  # Fonts and images
  - url: /(.+\.(eot|otf|tt[cf]|woff2?|cur|gif|ico|jpe?g|png|svgz?|webp))
    static_files: dist/\1
    upload: dist/(.+\.(eot|otf|tt[cf]|woff2?|cur|gif|ico|jpe?g|png|svgz?|webp))
    secure: always
    http_headers:
      Access-Control-Allow-Origin: "*"

  # CSS, Javascript, text and other file types
  - url: /(.+\.(css|js|xml|txt|map))
    static_files: dist/\1
    upload: dist/(.+\.(css|js|xml|txt|map))
    expiration: "10m"
    secure: always

  # HTML pages
  - url: /(.+\.html)
    static_files: dist/\1
    upload: dist/(.+\.html)
    expiration: '10m'
    secure: always
    http_headers:
      X-UA-Compatible: 'IE=edge'

  # Index entry point
  - url: /.*
    static_files: dist/index.html
    upload: dist/index.html
    expiration: '10m'
    secure: always
    http_headers:
      X-UA-Compatible: 'IE=edge'

  # Subpage entry point
  - url: /subpage/.*
    static_files: dist/subpage.html
    upload: dist/subpage.html
    expiration: '10m'
    secure: always
    http_headers:
      X-UA-Compatible: 'IE=edge'
  

skip_files:
  - ^(.*/)?app\.yaml
  - ^(.*/)?app\.yml
  - ^(.*/)?#.*#
  - ^(.*/)?.*~
  - ^(.*/)?.*/RCS/.*
  - ^(.*/)?\..*
  - ^(.*/)?tests$
  - ^(.*/)?test$
  - ^test/(.*/)?
  - ^COPYING.LESSER
  - ^README\..*
  - \.gitignore
  - ^\.git/.*
  - \.*\.lint$
  - ^node_modules/(.*/)?
  - public/*
  - src/*

【问题讨论】:

    标签: google-app-engine google-app-engine-python


    【解决方案1】:

    您的问题是- url: /.* 捕获了尚未捕获的所有内容。所以,处理程序永远不会到达/subpage/.*

    /subpage/.* 处理程序移到通配符- url: /.* 上方:

    # Subpage entry point
    - url: /subpage/.*
      static_files: dist/subpage.html
      upload: dist/subpage.html
      expiration: '10m'
      secure: always
      http_headers:
        X-UA-Compatible: 'IE=edge'
    
    # Index entry point
    - url: /.*
      static_files: dist/index.html
      upload: dist/index.html
      expiration: '10m'
      secure: always
      http_headers:
        X-UA-Compatible: 'IE=edge'
    

    【讨论】:

    • 谢谢,你让我头疼不已。
    猜你喜欢
    • 1970-01-01
    • 2019-12-06
    • 2013-08-12
    • 2012-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    相关资源
    最近更新 更多