如何在Azure CDN上设置重写规则以提供与路径模式不匹配的index.html? [英] How to setup a rewrite rule on Azure CDN to serve index.html that don't match a path pattern?

查看:108
本文介绍了如何在Azure CDN上设置重写规则以提供与路径模式不匹配的index.html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Azure CDN(显然由EdgeCast驱动)为我的React + GraphQL Web应用程序提供静态内容。

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

CDN将拉来自存储帐户的静态文件,Node.js将处理GraphQL端点。

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

为使客户端路由正常工作,我需要提供 /static/index.html 用于所有与静态内容路径不匹配的请求( /static/somefile.ext )。

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).

我想避免使用Node.js以这种方式为 index.html 提供服务:

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");
});


推荐答案

如果您使用的是Verizon Premium SKU,则可以通过在azure门户中单击管理来访问规则引擎。

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

我将使用这样的规则来重写除静态链接到index.html以外的所有内容

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

这篇关于如何在Azure CDN上设置重写规则以提供与路径模式不匹配的index.html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆