[英]Multiple React sites on the same Azure storage account
There is a need to improve our CI/CD process for our React application.需要改进我们的 React 应用程序的 CI/CD 流程。 The bottom line is:底线是:
So we want to have multiple React applications on the same storage account/CDN endpoint.所以我们希望在同一个存储帐户/CDN 端点上有多个 React 应用程序。 This would allow our QA team to test features independently.这将允许我们的 QA 团队独立测试功能。
I already made the following changes in the app that allows the app to work using relative path on localhost:我已经在应用程序中进行了以下更改,允许应用程序使用本地主机上的相对路径工作:
"homepage": "http://localhost:3001/testApp"
<Router basename={process.env.RELATIVE_ROOT_URL} {...props}>
...
3). 3)。 add a line to the .env file:在 .env 文件中添加一行:
RELATIVE_ROOT_URL=/testApp
But I don't have any idea how to change URL rewrite rule for CDN endpoint to allow to open URLs like {rootUrl}/{branchName}/somepath/ directly.但我不知道如何更改 CDN 端点的 URL 重写规则以允许直接打开像{rootUrl}/{branchName}/somepath/这样的 URL。
PS Currently we have the following rule that works well for a single site per CDN endpoint: PS 目前我们有以下规则适用于每个 CDN 端点的单个站点:
Condition :条件:
Action :行动:
Try the following:请尝试以下操作:
"homepage": ".",
to your package.json as it is mentioned here .将"homepage": ".",
到您的 package.json 中,因为它是在这里提到的。Router
to HashRouter
and remove the basename
attribute.将Router
更改为HashRouter
并删除basename
属性。Here is my example from this repo .这是我来自这个repo 的例子。
I deploy using the following command:我使用以下命令进行部署:
az storage blob upload-batch \
--account-name $(AZURE_STORAGE_ACCOUNT) \
--account-key $(AZURE_STORAGE_KEY) \
-s ./build/. \
-d '$web/product/book-shelves'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.