Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json Heroku上的Rails应用程序-与CORS一起发布_Json_Ruby On Rails 3_Heroku_Cors - Fatal编程技术网

Json Heroku上的Rails应用程序-与CORS一起发布

Json Heroku上的Rails应用程序-与CORS一起发布,json,ruby-on-rails-3,heroku,cors,Json,Ruby On Rails 3,Heroku,Cors,我在Heroku上有一个Rails应用程序,配置如下: module MyAppApi class Application < Rails::Application # other configs config.middleware.use Rack::Cors do allow do origins '*' resource '*', :headers => :any,

我在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
GET和POST的响应相同。你知道这里发生了什么吗?提前感谢。

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


routes.rb
是什么样子的?
$ 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