3

I have a React SPA that is being hosted as an Azure Static Website. The configuration is rather simple - html, js etc files are deployed to Azure Storage. I then enable the static website feature and expose this via a Verizon Premium CDN Endpoint.

The Static Website is configured to serve index.html as the index and error document. The issue that I am seeing here is that when a route is requested /faqs for example the response is a 404 with the index.html doc as the response body - this works fine in the browser but Google will not crawl it as it's seeing the response as a 404.

I wonder if there is anyway around this? Is there anyway to force 2** response codes?

jonytek
  • 111
  • 2
  • 7

2 Answers2

1

Well after messing around trying to configure Azure to force status codes I found a solution, it's not ideal but it works and will be fine for now.

SOLUTION: I cloned my index.html as faqs (no extension so manually set content type) so that the respective version is served when requested. Happy days! Glad I only have a small number of public pages.

jonytek
  • 111
  • 2
  • 7
  • how did it work for you? when I clone my index.html to be something like "gallery", azure doesn't serve the page as a web page, it only downloads it to the client, and when I change it to "gallery.html", all I get is an empty page. it looks like the only file possible to use is index.html – user1671400 Oct 04 '19 at 16:28
1

Since you have the CDN layer in front of your website, you can have the CDN deliver the index.html via a URL rewrite rather than relying on the static website's "error page" delivery mechanism. This holds up even if you have a variable number of routes in your application.

Configure a rule in your CDN's Rules Engine that takes any path without a file extension (since we want normal requests for assets or script/style files to return those actual files) and rewrites to /index.html. Re-write means the URL of the actual request remains the same, but the file that gets delivered comes from the rewritten URL.

See this article for more.

tplusk
  • 899
  • 7
  • 15