首页 > 解决方案 > 如何在 Azure 上部署 Strapi CLI 应用程序

问题描述

我刚刚在本地机器上启动了新的 Strapi 项目,并将其保存在 bitbucket 存储库中。所以我需要在 Windows 环境中部署它 Azure。我已经在免费层的基础上成功部署了 Postgres,现在是一个节点 Web 应用程序,我在 web.config 规则和部署方面遇到了问题

我尝试在自定义 web.config 周围搜索以重定向所有请求/public

<?xml version="1.0" encoding="utf-8"?>
<!--
     This configuration file is required if iisnode is used to run node processes behind
     IIS or IIS Express.  For more information, visit:
     https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
    <system.webServer>
        <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
        <webSocket enabled="false" />
        <handlers>
            <!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
            <add name="iisnode" path="{NodeStartFile}" verb="*" modules="iisnode"/>
        </handlers>
        <rewrite>
            <rules>
                <!-- Do not interfere with requests for node-inspector debugging -->
                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^{NodeStartFile}\/debug[\/]?" />
                </rule>

                <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
                <rule name="StaticContent">
                    <action type="Rewrite" url="public{PATH_INFO}"/>
                </rule>

                <rule name="Static Assets" stopProcessing="true">
                    <match url="([\S]+[.](html|htm|svg|js|css|png|gif|jpg|jpeg))" />
                    <action type="Rewrite" url="build/{R:1}"/>
                </rule>

                <rule name="Index" stopProcessing="true">
                    <match url="^$" />
                    <action type="Rewrite" url="public/index.html"/>
                </rule>

                <!-- All other URLs are mapped to the node.js site entry point -->
                <rule name="DynamicContent">
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
                    </conditions>
                    <action type="Rewrite" url="{NodeStartFile}"/>
                </rule>
            </rules>
        </rewrite>
        <!-- Make sure error responses are left untouched -->
        <httpErrors existingResponse="PassThrough" />
    </system.webServer>
</configuration>

显然这不满足 Strapi 路由要求。相反,我收到 500 内部路由错误。如何在可以访问我的管理面板和 api 的地方正确设置它?如何自定义我deploy.cmd的来做strapi build?在 Azure 上部署的正确方法是什么?

我还在这里为他们记录了一个问题到它的文档中

https://github.com/strapi/strapi/issues/3576

标签: node.jsazuredeploymentstrapi

解决方案


推荐阅读