Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

403 forbidden error when posting in expressjs

He all, I'm trying to post a new form, and i keep getting the following 403 error

Error: Forbidden
at Object.exports.error (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/utils.js:63:13)
at createToken (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/middleware/csrf.js:82:55)
at Object.handle (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/middleware/csrf.js:48:24)
at next (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.handle (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/view-helpers/index.js:65:5)
at next (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.handle (/Users/mark/Dropbox/Programming/mine/node/botappv2/config/express.js:70:7)
at next (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.handle (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/connect-flash/lib/flash.js:21:5)
at Context.next (/Users/mark/Dropbox/Programming/mine/node/botappv2/node_modules/express/node_modules/connect/lib/proto.js:193:15)

routes.js

module.exports = function (app, passport) {

  app.get('/', home.index)
  app.get('/dns_servers', dns_server.index)

  app.get('/dns_servers/new', dns_server.new)
  app.post('/dns_servers/create', dns_server.create)

  app.get('/dns_servers/:id', dns_server.show)

  app.get('/dns_servers/:id/edit', dns_server.edit)
  app.post('/dns_servers/:id', dns_server.update)

  app.post('/dns_servers/:id/delete', dns_server.delete)
}

form Action

form(action='/dns_servers/create',method='post')

Does anyone have any ideas on why this is creating a 403?

like image 768
mark Avatar asked Oct 30 '13 22:10

mark


1 Answers

The problem was the csrfl not being set.. I needed to set

        input(type="hidden", name="_csrf", value="#{csrf_token}")
like image 107
mark Avatar answered Oct 15 '22 12:10

mark