question

RaviKumarDega-7780 avatar image
0 Votes"
RaviKumarDega-7780 asked suvasara-MSFT answered

Ionic angular web app throwing 404 when hosted on Azure Storage Accounts

Hi, I have built and deployed an Ionic Angular web app to Storage accounts using Azure DevOps. To access the webpages I have configured Azure CDN. The home page of the website loads correctly but the subsequent pages throw 404 and even a refresh throws 404. Any help or guidance is appreciated. Thank you!

azure-storage-accountsazure-cdn
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @RaviKumarDega-7780 ,

Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

A 404 Not Found indicates that the requested content was not found on the origin server of Azure CDN.
Did you follow the below troubleshooting doc to validate the causes of the issue?
https://docs.microsoft.com/en-us/azure/cdn/cdn-troubleshoot-endpoint

Regards,
Gita

0 Votes 0 ·

1 Answer

suvasara-MSFT avatar image
1 Vote"
suvasara-MSFT answered

@RaviKumarDega-7780, This is expected behavior while you are hosting a static website on Azure storage account. The blob endpoint serves data only for the index.html path and throws 404 errors whenever there is an unknown path in the URL. While refreshing there are chances of adding extra elements to the URL of the blob that causes the 404 error. There are two ways in which you can avoid this 404 error for unknown paths,

Replace Error document with Index.html,

171661-image.png


or

Use Azure CDN rules engine concept for rewriting the source path to destination index.html,

171587-image.png



Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.




image.png (19.2 KiB)
image.png (53.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.