我在 Heroku 上有一个具有以下配置的 Rails 应用程序:
module MyAppApi
class Application < Rails::Application
# other configs
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*',
:headers => :any,
:methods => [:get, :post, :delete, :put, :options]
end
end
end
end
我的问题是任何请求都以 301 状态返回。例如:
$ curl \
-i -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-X OPTIONS 'http://myappapi.heroku.com/api/v1/resource.json'
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 17 May 2013 14:56:00 GMT
Content-Length: 0
Connection: keep-alive
Location: http://myappapi.heroku.com/api/v1/resource.json
GET、POST 的响应相同。关于这里发生了什么的任何想法?提前致谢。