2

我在 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 的响应相同。关于这里发生了什么的任何想法?提前致谢。

4

1 回答 1

2

您正在请求.heroku.com 域。尝试改为请求“ .herokuapp.com”

https://devcenter.heroku.com/articles/error-codes#h16-redirect-to-herokuappcom

于 2013-05-17T18:42:36.297 回答