1

We have to add SEO capabilities to our full client side rendered SPA.

We already did all the heavy lifting regarding the refactoring to make it SEO optimized. (History mode for routing, all crawlable links, proper robots.txt, proper head tags, sitemap.xml, ...)

Everything seems pretty fine regarding all the docs we could find online about SEO with SPAs. However, when testing our urls we are hitting some troubles:

  • In Google Search Console, the URLs fail the live test
  • In dnschecker.org, the HTTP response Headers Check returns a 404 for all our routes
  • Only the root URL is responding OK If I open directly any URL in any browser with incognito mode, everything works as expected.

We are hosting the application on an Azure Storage container for static delivery. The entry point is properly set to index.html, the errors entry point also at index.html. We also set a redirect rule from http requests to https.

We thought it might be an URL rewrite sorta thingy, but we couldn't find anything relevant.

Any lead would be awesome !

1

The fundamental problem here seems to be that your routes return 404, when for a Single Page App, they need to return 200. A 404 status code basically tells Google / Headers Check / everyone else "go away, there's nothing here".

Here's a resource I found for how to configure routes on azure for an SPA:

https://medium.com/medialesson/best-way-to-host-a-single-page-application-spa-in-microsoft-azure-3e70cbd075c3

Here's the key snippet from the "Configure Routing" section of the article:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="SPA" stopProcessing="true">
          <match url="^(?!.*(.js|.css|.png|.jpg|.ico|.svg)).*$" />
          <conditions logicalGrouping="MatchAll">
          </conditions>
          <action type="Rewrite" url="/"  appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
| improve this answer | |
  • Nice article ! However I mentioned we're using the Azure storage approach so the web.config is not a solution. – Pierre Burton Aug 18 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.