Skip to content

Conversation

alishx31
Copy link

@alishx31 alishx31 commented Mar 9, 2021

cors enabled in nodejs chat server before server initialized

const http = require('http');
const socketio = require('socket.io');
const socketEvents = require('./utils/socket');
let cors = require('cors');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use const here

Comment on lines -9 to +22
constructor() {
this.port = process.env.PORT || 3000;
constructor() {
this.port = process.env.PORT || 3000;
this.host = process.env.HOST || `localhost`;

this.app = express();
this.app.use(cors());
this.http = http.Server(this.app);
this.socket = socketio(this.http);
}
}

appRun(){
new socketEvents(this.socket).socketConfig();
this.app.use(express.static(__dirname + '/uploads'));
appRun() {
new socketEvents(this.socket).socketConfig();
this.app.use(express.static(__dirname + '/uploads'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep 4 space indent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants