【发布时间】:2019-03-03 02:36:56
【问题描述】:
美好的一天!
我的同事有一个网站 node.js (next.js),当我们通过控制台构建和启动(npm run build 和 npm start)时,他的网站运行良好。
我们将它托管在 Azure VM 中(安装了 Windows Server 2016 IIS、iisnode 和 urlrewrite),我们创建了一个管道,我们能够获取工件(运行构建时的“.next”文件夹)并部署它到 IIS 但是我们仍然需要手动交互来放置 web.config。下面是web.config
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="service-worker.js" verb="*" modules="iisnode" />
</handlers>
<!-- use URL rewriting to redirect the entire branch of the URL namespace
to hello.js node.js application; for example, the following URLs will
all be handled by hello.js:
http://localhost/node/express/myapp/foo
http://localhost/node/express/myapp/bar
-->
<rewrite>
<rules>
<rule name="AMS" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
但是当我们访问该网站时,它会抛出一个需要提供默认页面的 403 错误。 (我迷路了,无法通过 IIS 运行他的网站)
注意:他的另一个网站运行良好(因为它有一个 service-worker.js)。
任何人都有将 Next.JS 部署到 IIS 的经验?提前致谢。
【问题讨论】:
-
嘿伙计,你有什么运气吗?
-
@Terkhos,对不起伙计,我们删除了项目中的 next.js。我们只坚持在 nodejs 中。
-
别担心,伙计。你现在用什么做 SSR?
标签: node.js iis next.js iisnode