繁体   English   中英

如何解决错误 HRESULT: 0x6d HTTP 500 substatus 1013 when Deployed in Azure with Node.js Express and IISnode?

[英]How to solve error HRESULT: 0x6d HTTP 500 substatus 1013 when Deployed in Azure with Node.js Express and IISnode?

当我尝试从联系表单发帖时,我的应用程序不断出现错误。 这是踢球者,它在我的本地主机开发环境中工作(接收电子邮件)。 当我从我的主机桌面将它部署到 vm Windows 服务器时,它甚至可以接收 email。 但是当我在 Azure Windows 服务器上部署它时它不起作用,我的虚拟机服务器和 Azure 在 IIS 中具有相同的设置,安装了 node.js 和 IISnode。 对整个 node.js/express 和 IISnode 开发来说有点新,任何帮助它工作和解决的帮助将不胜感激。

错误截图。

web.config

<configuration>
    <system.webServer>
        <handlers>
            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>
        <!-- <httpErrors existingResponse="PassThrough"> -->
        <iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" logDirectory="C:\inetpub\logs\abc\iisnode" loggingEnabled="true" />
        <modules runAllManagedModulesForAllRequests="false">
            <remove name="WebDAVModule"/>
        </modules>
        <rewrite>
            <rules>
                <rule name="abc_test">
                    <match url="api/*" />
                    <action type="Rewrite" url="server.js" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

服务器.js

const PORT = process.env.PORT || 3003`
const app = require('./app')
app.listen(PORT, function(){
     `console.log("Server Listening On Port: ", PORT);
})

应用程序.js

const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));`
app.use(cors({origin: "*"}));
const generalRoutes = require('./api/route/general');
app.use('/'+'abc_backend/api/general/', generalRoutes);
module.exports = app;

通用.js

const express = require('express');
const router = express.Router();
const gController = require('../controller/generalController');
router.post('/contacting', gController.sendingMail);
module.exports = router;

通用控制器.js

const express = require('express');
const bodyParser = require('body-parser');
const nodemailer = require('nodemailer');
const app = express();
const sendingMail = async(req, res) => {
 let user = req.body;
 let transporter = nodemailer.createTransport({
 host: "smtp.gmail.com",
 port: 465,
 secure: true, // true for 465, false for other ports
 auth: {
  user: "aasome.fakemailzz@gmail.com",
  pass: "somefakepass"
 }
});
let mailOptions = {
 from: "contact@somefakedomain.io",
 to: "fakename@somefakedomain.com",
 subject: "New Contact Message",
 html: <b>Name: </b> ${user.userName} <br>
 <b>Email: </b> ${user.email} <br>
 <b>Phone: </b> ${user.address.postalCode} <br>
 <b>Message: </b> ${user.address.city}
};
let info = await transporter.sendMail(mailOptions);
 res.send(info);
}
module.exports = {
 sendingMail
}

联系.service.ts

export class ContactingService {
 public url:string;
 constructor(private _http: HttpClient) {
  this.url = environment.backendAPIurl + "/general/";
 }
 contactSubmit(userName: string, email: string, postalCode: string, city: string){
  const bodyData = {
   userName:userName,
   email: email,
   address:{
    postalCode:postalCode,
    city: city
   }
  }
  return this._http.post<any>(this.url +"contacting",bodyData);
 }
}

解决了。 看了一下启用IIS_USr后的错误日志,将日志写入web.config中的目录。 该错误表明它是谷歌身份验证问题,如果传入请求服务器不安全/SSL,则在生产服务器上谷歌将无法工作。

还发现了一个提到相同概念的 stackoverflow 链接。 iisnode 在处理请求时遇到错误。 HRESULT:0x6d HTTP 状态:500 HTTP 子状态:1013

通过单击此链接并使用来自 nodemailer.createTransport({}) 的帐户登录以允许它来解决。 https://accounts.google.com/b/0/DisplayUnlockCaptcha

暂无
暂无

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

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