I'm trying to host a React app in Azure blob storage. To do this I need to rewrite all requests to /index.html, while preserving the url in the browser. Various articles describe using Azure CDN to perform the URL Rewrite to direct all requests through index.html. I haven't been able to get this working, here's what I have tried:
Asked
Active
Viewed 342 times
0
-
After reading your description, you can carefully describe the effect you want, such as what is the access URL and what is the rewritten URL? – Jason Jan 06 '21 at 04:07
-
I think what you need is url redirect, not url rewrite. – Jason Jan 06 '21 at 04:08
-
question updated, thanks. It does need to be a rewrite and not a redirect as the url needs to be preserved – Mike Simmons Jan 06 '21 at 10:44
-
You should create CDN resource in the portal with `Premium Verizon` pricing tier. – Jason Jan 07 '21 at 04:10
-
[Blogs 1](https://medium.com/@antbutcher89/hosting-a-react-js-app-on-azure-blob-storage-azure-cdn-for-ssl-and-routing-8fdf4a48feeb) clearly tells us how to use it, but currently there seems to be a problem with rule engine 4.0. It is recommended to use web.config for rewrite. – Jason Jan 07 '21 at 05:06
-
If you still want to use cdn for rewrite, you can refer to the document for operation. These two posts should also be helpful to you. [post1](https://stackoverflow.com/questions/58697519/azure-cdn-verizon-custom-rewrite-rule-invalid-origin) and [post2](https://stackoverflow.com/questions/62647432/azure-cdn-premium-verizon-rules-engine-v4-url-rewrite-for-storage-static-website). – Jason Jan 07 '21 at 05:08
-
Has your problem been solved? Is there any progress? – Jason Jan 08 '21 at 01:25
-
Thanks for your help Jason, I'm currently waiting for Microsoft support to get back to me as they think it should be possible in the standard rules engine (cheaper than verizon premium). Will update here when I hear from them. – Mike Simmons Jan 08 '21 at 09:50
-
If you solved the issue, you can post your answer here can help more forum user. – Jason Jan 13 '21 at 05:38
-
hasn't been resolved yet, I will post answer if it ever comes – Mike Simmons Jan 13 '21 at 09:07
-
If possible, you can add `web.config` file to use rewrite. – Jason Jan 13 '21 at 09:08
-
it's hosted in azure storage - web.config will only work if i host in a web app right? – Mike Simmons Jan 13 '21 at 09:11
-
I'm not sure, you can try it. If failed, you need to find another way. – Jason Jan 13 '21 at 09:13
1 Answers
0
I've managed to resolve this using this answer:
https://stackoverflow.com/a/63197547/983599
I had basically picked the wrong condition type, instead of "Request URL" less than 1, it should have been "URL file extension":
Mike Simmons
- 1,278
- 1
- 9
- 22