简体   繁体   English

在Express中包装的Azure NextJs应用程序上部署后,应用程序将永远加载

[英]After Deploying on Azure NextJs App wrapped in Express, app loads forever

Hi I am trying to deploy nextjs app using devOps project with server.js which looks like that: 嗨,我正在尝试使用带有dev.ps项目的server.js部署nextjs应用,如下所示:

 const express = require('express') const next = require('next') const dev = process.env.NODE_ENV !== 'production' const app = next({ dev }) const handle = app.getRequestHandler() app.prepare() .then(() => { var port = process.env.port || 3001 const server = express() server.get('*', (req, res) => { return handle(req, res) }) server.listen(port, (err) => { if (err) throw err console.log('> Ready on http://localhost:433') }) }) .catch((ex) => { console.error(ex.stack) process.exit(1) }) 

For devOPs project I set up github, vsts and then it goes off to azure. 对于devOPs项目,我设置了github,vtss,然后变成了Azure。

I used the default set up for nodejs, only what I did additionaly in VSTS pipelines I added npm script "npm run build". 我使用了默认的nodejs设置,只是我在VSTS管道中做了额外的工作,添加了npm脚本“ npm run build”。

My agent job in buld looks like this: 我的代理商工作可能如下所示:

  • -User node version -用户节点版本
  • -Npm install application dependencies -Npm安装应用程序依赖项
  • -Npm custom (Added by me, run build) -Npm自定义(由我添加,运行构建)
  • -Archive Files 存档文件
  • -Public Artifact drop. -公共神器掉落。

And in release: 并在发行中:

  • Azure Deployment: Create Azure App Azure部署:创建Azure应用
  • Deploy Azure App Service 部署Azure应用服务

The problem is that Build succedes same as release, but then when I try to access the website it loads forever. 问题是,Build与发布成功相同,但是当我尝试访问该网站时,它将永远加载。 I did my research but found nothing. 我做了研究,但一无所获。

I have been trying to make it work for 3 days now... Please help 我已经尝试使其工作3天了...请帮助

Yesterday I successfully deployed NextJs App to Azure App service by using Azure Devops build and release pipelines. 昨天,我使用Azure Devops构建和发布管道成功地将NextJs App部署到Azure App服务。

Below are three issues I faced. 以下是我面临的三个问题。 I am also sharing solution screenshots for each issue. 我还将分享每个问题的解决方案屏幕截图。

  1. Azure App service Node version should be compatible with your nextjs. Azure App服务节点版本应与您的nextjs兼容。

    https://i.imgur.com/UPDc9GE.png https://i.imgur.com/UPDc9GE.png

  2. Missing web.config file at root 根目录缺少web.config文件

    https://i.imgur.com/EZRTT4P.png https://i.imgur.com/EZRTT4P.png

  3. Incorrect port number in server.js and incorrect script tags in package.json server.js中的端口号不正确,package.json中的脚本标记不正确

    https://i.imgur.com/PJadc7b.png https://i.imgur.com/PJadc7b.png

My build pipeline looks similar like you. 我的构建管道看起来像您一样。 https://i.imgur.com/0Y8m2wH.png https://i.imgur.com/0Y8m2wH.png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM