首页 > 解决方案 > 我无法在 azure 上部署我的 nextjs 应用程序

问题描述

我一直在尝试在 azure devops 项目服务上部署我的 next.js 应用程序。

我已经设置了与 azure repos 链接的项目的 CI 和 CD。即使我的管道成功,我也会收到“内部服务器错误”或“应用程序错误”,即使应用程序在我的本地运行良好。

我尝试了一个节点应用程序,它运行相同的管道任务。

我已经尝试添加一个 web.config 文件,但仍然没有运气。

谁能建议我我可以错过什么?

添加 web.config 文件 在发布管道中禁用 web.config 选项 在管道中添加新任务,例如 npm run build

我的 web.config 文件如下:

    <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
    <rule name="StaticContent">
      <action type="Rewrite" url="public{REQUEST_URI}"/>
    </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="server.js"/>
    </rule>
  </rules>
</rewrite>

<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
  <requestFiltering>
    <hiddenSegments>
      <remove segment="bin"/>
    </hiddenSegments>
  </requestFiltering>
</security>

<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />

<!--
  You can control how Node is hosted within IIS using the following options:
    * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
    * node_env: will be propagated to node as NODE_ENV environment variable
    * debuggingEnabled - controls whether the built-in debugger is enabled
  See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->

我的应用程序端点给出了应用程序错误结果,即使我认为我已经完成了几乎整个过程。

标签: azureazure-devopsnext.js

解决方案


推荐阅读