我正在使用 Tower.js 0.4.2-20。
我发送了 HTML FORM 标签的 GET 和 POST 请求。
'GET' 请求是没有问题的响应。但“POST”请求是返回以下错误。
我缺少路由器设置?
路线.咖啡:
Tower.Route.draw ->
@resources 'service'
@match '/service/add', to: 'service#add', via: 'post'
服务控制器.coffee:
class ServiceController extends App.ApplicationController
index: ->
@render text: "GET"
create: ->
@render text: "POST"
add: ->
@render text: "ADD"
索引.html:
<form method='POST' action='service/add'>
<div><input type='submit' value='Add'></div>
</form>
错误 :
Error: Forbidden
at Object.exports.error (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/utils.js:44:13)
at Object.module.exports [as handle] (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/csrf.js:54:41)
at next (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at multipart (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/multipart.js:57:27)
at module.exports (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9)
at IncomingMessage.module.exports (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:68:11)
at IncomingMessage.EventEmitter.emit (events.js:115:20)
at Object.resume (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/node_modules/pause/index.js:25:18)
at store.get.next (/var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/session.js:311:15)
at /var/www/html/melissa/manage/development/yoshiaki-tanaka/node_modules/tower/node_modules/express/node_modules/connect/lib/middleware/session.js:333:9