Is this the correct way to redirect all route traffic based on useragent?
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Due to the fact my SPA application has hydration issues on ios (separate bug) I am currently in a position where I cannot use SSR, so I have to use an SPA and pre-rendered pages for SEO.
My application currently sits on azure static sites and I am very happy with the performance and devops integrations.
So i am looking at integrating a service where search engine bots are re-directed to a static copy of my site, this would be easy in IIS or Nginx, but ideally I would like to stay on static-web-app.
The service page-replica publishes these instructions:
1. Detect bot traffic using the User-Agent header (e.g., Googlebot, Bingbot, Facebook, Twitter, etc.).
2. Redirect bots to the prerendered cache URL (e.g., ```https://cache.page-replica.com/[siteId]/[domain]/[path])```.
3. Serve normal users your regular dynamic site as usual.
I *think* I can do this via ```staticwebapp.config.json```, but I am unsure.
Will the below wildcard routing and re-direct work?
```
{
"routes" : [
{
"route": "/*",
"redirect": "https://cache.page-replica.com/200/www.example.com/*",
"headers": {
"User-Agent": "Googlebot"
}
},
{
"route": "/*",
"redirect": "https://cache.page-replica.com/200/www.example.com/*",
"headers": {
"User-Agent": "bingbot"
}
}
],
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/images/*.{png,jpg,gif}", "/css/*"]
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.