Getting history mode to work with Vue app deployed

2019-08-20 06:29发布

问题:

I managed to break my site on Google cloud. If you navigate to my domain, it works fine http://www.quantumjs.com/

but if you go to a route my app directly, GC isn't redirecting to index.

ie http://www.quantumjs.com/events

I followed this tutorial but modified it for my vue app

https://medium.com/google-cloud/how-to-deploy-a-static-react-site-to-google-cloud-platform-55ff0bd0f509

I thought this app.yaml would do the job: runtime: python27 api_version: 1 threadsafe: true handlers: - url: / static_files: dist/index.html upload: dist/index.html - url: / static_dir: dist

EDIT

this was my working solution

runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(js|css|png|jpg))$
  static_files: dist/\1
  upload: dist/.*\.(js|css|png|jpg)$
  # catch all handler to index.html
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

回答1:

Try redirecting all your url access to the index.html

handlers:
  # handle static files, change the path according to your need
- url: /(.*\.(js|css))$
  static_files: static/\1
  upload: static/.*\.(js|css)$
  # catch all handler to index.html
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

Read more in here.