How to setup a rewrite rule on Azure CDN to serve index.html that don't match a path pattern?

*爱你&永不变心* 提交于 2019-12-14 02:14:48

问题


I want to use Azure CDN (which is powered by EdgeCast, apparently) to serve static content for my React + GraphQL web app.

The CDN will pull the static files from a Storage account, and Node.js will handle the GraphQL endpoint.

For the client-side routing to work properly, I need to serve /static/index.html for all requests that don't match the static content path (/static/somefile.ext).

I want to avoid using Node.js to serve the index.html in this fashion:

var express = require('express');
var app = express();

app.all('*', function(req, res){
  res.sendfile("index.html");
});

回答1:


If you are using a Verizon Premium SKU, you can access the rules engine by clicking 'Manage' from the azure portal.

I would use a rule like this to rewrite everything except your static link to index.html




回答2:


You could try to use the "Modify Client Response Header" feature:



来源:https://stackoverflow.com/questions/39800105/how-to-setup-a-rewrite-rule-on-azure-cdn-to-serve-index-html-that-dont-match-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!