You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure部署Next.js+自定义Express/Node.js应用权限错误求助

Azure部署Next.js+Express应用出现「您无权查看此目录或页面」问题

我在Azure部署了一个前端基于Next.js(包含getStaticProps函数)、后端为自定义Express/Node.js的应用,应用还使用了MySQL(但我认为这与当前问题无关)。部署完成后,页面显示「您无权查看此目录或页面」。

我的Express路由文件位于server/index.js,已配置web.config、iisnode.yml、package.json和jsconfig.js文件,具体内容如下,且Azure应用的所有环境变量已配置完毕。已为此困扰数日,恳请协助解决。

web.config内容

<configuration>
  <system.webServer>
    <handlers>
      <add name="iisnode" path="server/index.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <rule name="NodeServer" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="server/index.js" />
          <action type="Rewrite" url="server/index.js" />
        </rule>
        <rule name="NextJsRouting" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="server/index.js" />
        </rule>
      </rules>
    </rewrite>
    <iisnode nodeProcessCommandLine="&quot;C:\Program Files\nodejs\node.exe&quot;" />
  </system.webServer>
</configuration>

iisnode.yml内容

nodeProcessCommandLine: "node server/index.js"

package.json内容

{
  "name": "endelig",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "nodemon server/index.js",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@next/font": "13.1.6",
    "@stripe/react-stripe-js": "^2.1.0",
    "@stripe/stripe-js": "^1.52.0",
    "bcrypt": "^5.1.0",
    "cookie-parser": "^1.4.6",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "jsonwebtoken": "^9.0.0",
    "micro": "latest",
    "micro-cors": "latest",
    "mysql": "^2.18.1",
    "next": "^13.1.6",
    "nodemailer": "^6.9.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "stripe": "^11.17.0"
  }
}

jsconfig.js内容

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./*"]
    }
  }
}

内容的提问来源于stack exchange,提问作者ShAf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 00:00:32