在 Azure 上部署条带支付网关

Viv*_*vek 2 azure stripe-payments azure-web-app-service azure-devops

经过大量研究,关注 YouTube 视频https://youtu.be/Ny5vJRfQito并将支付网关部署到 Azure。

但是,在付款时,遇到以下问题,说明没有找到 payment_intent.js

404 payment_intent.js 未找到错误

控制台出错

在此处输入图片说明

以下是存储库中可用文件的屏幕截图

DevOps Repo 中可用的文件

在此处输入图片说明

借助URL https://myapp.scm.azurewebsites.net/DebugConsole/?shell=powershell导航到Azure App Service,发现文件不在列表中,如下图

Azure 应用服务中的文件列表

在此处输入图片说明

谷歌搜索了很多,但找不到解决方案。

如果这里有人可以帮助我在 Azure 上进行部署以及需要采取哪些其他步骤来解决问题,我将不胜感激。

如果需要任何其他详细信息,请告诉我

提前致谢

更新

这是一个 Next.js 应用程序,最终的项目文件存储在OUT文件夹中,因为 next.js 没有构建文件夹,如下所示。同样的文件也显示在 www 根目录下。

代码在 localhost 上运行良好,以下是完整的文件夹结构

项目文件夹结构

下面是构建管道的屏幕截图

构建管道

下面是out文件夹

文件夹结构和文件

Dor*_* Lv 8

我使用您的代码重现了 404 错误,并注意到您使用了 next.js 项目,这在 Azure 中与本地略有不同。

您需要两个文件:server.jsweb.config,并按package.json如下方式修改。我用你的代码进行了测试,它在我这边工作得很好。

package.json修改。

"scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "node server.js"
Run Code Online (Sandbox Code Playgroud)

server.js(使用以下代码创建此文件:)

const { createServer } = require('http')
const next = require('next')

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare().then(() => {
  createServer((req, res) => {
    const parsedUrl = new URL(req.url, 'http://w.w')
    const { pathname, query } = parsedUrl

    if (pathname === '/a') {
      app.render(req, res, '/a', query)
    } else if (pathname === '/b') {
      app.render(req, res, '/b', query)
    } else {
      handle(req, res, parsedUrl)
    }
  }).listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})
Run Code Online (Sandbox Code Playgroud)

web.config(使用以下代码创建此文件:)

<?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="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/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{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"/>-->
  </system.webServer>
</configuration> 
Run Code Online (Sandbox Code Playgroud)

参考:无法将下一个js部署到azure


这是我做的步骤:

上一篇:添加web.configserver.js和修改package.json

1. 创建构建管道。

在此处输入图片说明 在此处输入图片说明

2. 创建发布管道。

在此处输入图片说明 在此处输入图片说明

3. 运行构建-->触发发布。

下载并检查工件:

在此处输入图片说明

  1. 检查部署在 Azure 中的 Web 应用。 在此处输入图片说明 在此处输入图片说明