question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rails 5.0.0 - Access-Control-Allow-Origin

See original GitHub issue

Hello,

I run rails 5.0 on heroku and i’ve followed all steps but the following error persists:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://kabrabom.herokuapp.com’ is therefore not allowed access.

File config.ru:

use Rack::Cors do
  allow do
    origins 'localhost:3000', '127.0.0.1:3000',
            /\Ahttp:\/\/192\.168\.0\.\d{1,3}(:\d+)?\z/
    resource '/file/list_all/', :headers => 'x-domain-token'
    resource '/file/at/*',
        :methods => [:get, :post, :delete, :put, :patch, :options, :head],
        :headers => 'x-domain-token',
        :expose  => ['Some-Custom-Response-Header'],
        :max_age => 600

  end
  allow do
    origins '*'
    resource '/public/*', :headers => :any, :methods => :get
  end
end

File config/application.rb:

config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins '*'
        resource '*', :headers => :any, :methods => [:get, :post, :options]
      end
    end

Middleware output:

use Rack::Cors
use Rack::Sendfile
use ActionDispatch::Static
use ActionDispatch::Executor
use ActiveSupport::Cache::Strategy::LocalCache::Middleware
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Callbacks
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Warden::Manager
run Kabrabom::Application.routes

Postman’s plugin results:

Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01
X-DevTools-Emulate-Network-Conditions-Client-Id:747d2432-8d59-43e3-aa3e-62baac1833ca,747d2432-8d59-43e3-aa3e-62baac1833ca
Origin:http://kabrabom.herokuapp.com
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Referer:http://kabrabom.herokuapp.com/professional_professions/new?_sm_au_=iFVn48qbQPRVWLGM
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4

Important: I am connected by my company’s proxy.

I d really thankfull if you @cyu can help me.

Thanks!!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:23
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
niketa741commented, Mar 11, 2019

@vlbgomes Were you able to resolve your issue? Please tell me if you did, I am facing the same problem.

0reactions
cyucommented, May 7, 2020

I’m closing this issue because of inactivity from the original submitter.

If you’re still having problems. Please create a new issue and provide the specifics.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome saying "No Access-Control-Allow-Origin header ...
Earlier I was using heroku to server static assets. Then I decided to use cloud front to serve static assets for my rails(5.0.2)...
Read more >
Received CORS issue trying to reproduce quickstart demo in ...
I tried to add auth0 to a Rails web app following the quickstart demo ... has been blocked by CORS policy: No 'Access-Control-Allow-Origin'....
Read more >
actionpack 5.0.7.2 → 5.1.0.beta1 - Diffend
Rails 5.0.0 (June 30, 2016) ## ... 'Access-Control-Allow-Origin' when a response is delivered. They can be. 673. - configured with `#config`:.
Read more >
Webpacker failing to compile environment.js after upgrade to ...
For some odd reason, I receive "Invalid configuration object. Webpack has been initialised using a configuration object that does not match ...
Read more >
README — Documentation for rack-app (7.6.5) - RubyDoc.info
require 'rack/app' class App < Rack::App mount SomeAppClass headers 'Access-Control-Allow-Origin' => '*' ... rails, 5.0.0, 33.234, 0.0007329187002032537.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found