I would like to serve static files depending on the query parameter. More specificly I would like to serve prerendered snapshots for search engine optimalization. The pages are hosted on Google Appengine, so I'm using app.yaml to define these urls.
handlers:
# Consider anything matching a dot static content.
- url: /(.*\..*)$
static_files: dist/\1
upload: dist/(.*\..*)$
# Serve snapshots for seo
- url: /?_escaped_fragment_=(.*)
static_files: dist/snapshots/\1
upload: dist/(.*)$
# Otherwise let Angular handle it.
- url: /(.*)
static_files: dist/index.html
upload: dist/index.html
However, when I fetch a url with the query parameter _escaped_fragment_
, the last url handler is triggered. Is it possible to define query params in urls? If so, what am I doing wrong?
I had the exact same problem. It is kind of lame that App Engine hasn't added the ability to dispatch on static query parameters... Anyway.
This code basically guesses whether you are dispatching on the
_escaped_fragment_
query parameter and modifies the output accordingly. I have no idea how much less (if any) performant this is than being able to just leaveindex.html
in thestatic_files:
handlers inapp.yaml
.I'm happy to be proven wrong, but I'm pretty sure that query parameters aren't considered when dispatching via
app.yaml
.