![](/img/trans.png)
[英]How NodeJS app access resources from a disabled CORS(Cross Origin Sharing) Server using HTTP requests?
[英]How to access nodejs server with https requests in mvc core web app?
我正在開發一個基於 socket.io 的聊天應用程序,它具有不同的客戶端,即 android、ios 和 Z2567A5EC9305EB7AC2DZE9804。 聊天在 android 和 iOS 應用程序中正常工作。
Nodejs 服務器用作 socket.js 通信的后端。 Web 部分在 asp.net mvc core 3.1 中實現。 我已經通過 openssl 創建了自簽名證書,以通過 https 訪問 nodejs 服務器。 我使用了以下代碼
varhttp = require('http');
var express = require('express');
var app = express();
const httpsPort = 1234;
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('./key.pem', 'utf8'),
cert: fs.readFileSync('./server.crt', 'utf8')
};
var secureServer = https.createServer(options, app).listen(httpsPort, () => {
console.log("listening at port " + httpsPort);
});
但是 nodejs 服務器沒有連接,並且顯示了不同的錯誤
socket.io.js:14 GET https://x.xxx.xx.xx:8083/socket.io/?EIO=3&transport=polling&t=NRU7hkg net::ERR_CERT_AUTHORITY_INVALID
或者
證書在 chrome 中無效,帶有以下 msg
This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store.
如何通過 https 正確配置 nodejs 服務器以與作為 mvc 核心 3.1 web 應用程序的客戶端通信而沒有瀏覽器安全問題/未找到服務器問題?
您尚未將 http 聲明為變量嘗試在第一行執行此操作
var http = 要求('http');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.