【问题标题】:Heroku: What will be the hostname and port of my deployed socket.io appHeroku:我部署的 socket.io 应用程序的主机名和端口是什么
【发布时间】:2021-06-27 10:21:29
【问题描述】:

我有一个 socket.io 应用程序,我想在 heroku 上托管。这是我的第一个 heroku 部署,我不确定我的应用程序的主机名和端口是什么。 server.js 文件是这样的:

const http = require('http').createServer();
const questions = require('./Questions');
const dares = require('./Dares');
const rathers = require('./WYRather');
const nhie = require('./NHIE');

const io = require('socket.io')(http, {
    cors: { origin: "*"}
});

http.listen(process.env.PORT || 8080, () => {
    console.log("Server listening on: http://localhost:8080");
});

【问题讨论】:

    标签: javascript heroku socket.io


    【解决方案1】:

    主机名是${your-project-name}.herokuapp.com

    在部署之前无法确定端口,即process.env.PORT

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-09
      • 2011-02-04
      • 2010-12-29
      • 2018-06-19
      • 2015-04-29
      • 2016-01-26
      • 2016-07-11
      • 2020-09-05
      相关资源
      最近更新 更多