Home > Back-end >  Host static website on Azure without $web in URL
Host static website on Azure without $web in URL

Time:10-21

Following instructions in Static website hosting in Azure Storage and Add a custom domain to your endpoint I've managed to get a static website with a custom domain and https (albeit with a "www" subdomain) via Azure CDN.

However, the blob endpoint ends "/$web/index.html" and that is also required to access the custom domain. So it is of the form:

https://www.<customdomain>.com/$web/index.html

Because of the SPA framework I'm using, that immediately becomes:

https://www.<customdomain>.com/$web/index.html#/home

which is a bit long.

I see instructions for handling https on root custom domains and may give that try if I'm feeling brave. But is there a way to suppress the /$web/index.html part? Currently, if I go to:

https://www.<customdomain>.com

I get:

<Error>
  <Code>InvalidQueryParameterValue</Code>
  <Message>Value for one of the query parameters specified in the request URI is invalid. RequestId:...</Message>
  <QueryParameterName>comp</QueryParameterName>
  <QueryParameterValue/>
  <Reason/>
</Error>

CodePudding user response:

Instead of mapping your custom domain to regular blob endpoint (e.g. https://mystorageaccount.blob.core.windows.net/), please try to map it to static website endpoint which looks something like https://mystorageaccount.z22.web.core.windows.net.

Once you do that, then you will not need to specify $web in your requests as this endpoint always picks up the content from $web blob container.

You can find the static website endpoint for your storage account in going into Static website section for your storage account in Azure Portal.

  • Related