Skip to content

Commit

Permalink
Add cors to socket.io
Browse files Browse the repository at this point in the history
  • Loading branch information
sonsoleslp committed May 8, 2022
1 parent 8f05621 commit 4288456
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions controllers/user_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ exports.create = (req, res, next) => {
error.errors.forEach((err) => {
req.flash("error", validationError(err, i18n));
});
// console.log(error.errors[0])
// console.log(error.errors[0].validatorArgs)
// console.log(error.errors[0].path)
// console.log(error.errors[0].validatorKey)
// Console.log(error.errors[0])
// Console.log(error.errors[0].validatorArgs)
// Console.log(error.errors[0].path)
// Console.log(error.errors[0].validatorKey)
res.render("index", {user, "register": true, redir});
} else {
next(error);
}

}).catch(error=> next(error));
}).catch((error) => next(error));
};

// GET /users/:userId/edit
Expand Down Expand Up @@ -148,7 +147,7 @@ exports.update = (req, res, next) => {
res.redirect(`/users/${user_saved.id}/edit`);
}).
catch((error) => {
if (error instanceof Sequelize.ValidationError){
if (error instanceof Sequelize.ValidationError) {
error.errors.forEach(({message}) => req.flash("error", message));
res.render("users/edit", {user});
} else {
Expand Down
2 changes: 1 addition & 1 deletion io.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {checkAccess, getInfoFromSocket, socketAuthenticate, sendInitialInfo, init
const {getAuthMessageAndCode, NOT_A_PARTICIPANT, NOK} = require("./helpers/apiCodes");

exports.createServer = (server, sessionMiddleware) => {
const io = new Server(server, {"perMessageDeflate": false, "allowEIO3": true, "origin": "*" });
const io = new Server(server, {"perMessageDeflate": false, "allowEIO3": true, "cors": { "origin": "*", "methods": ["GET", "POST"]} });

io.use(function (socket, next) {
sessionMiddleware(socket.request, socket.request.res, next);
Expand Down

0 comments on commit 4288456

Please sign in to comment.