问题
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