8

大家,我正在尝试发布新表格,但我不断收到以下 403 错误

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)

路由.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='/dns_servers/create',method='post')

有没有人对为什么会创建 403 有任何想法?

4

1 回答 1

16

问题是没有设置csrfl ..我需要设置

        input(type="hidden", name="_csrf", value="#{csrf_token}")
于 2013-10-31T11:50:04.780 回答