Skip to content

Bypassing CORS error #56

Description

@yannp

Hi,

I would like to use rack-reverse-proxy in order to bypass a CORS error while accessing youtube via ajax from my website. I have the following JS code client-side:

    xhr = xhr.open 'GET', '/watch?v=0xc3XdOiGGI', true

    xhr.onload = ->
      console.log("XHR SUCCESS")
      return

    xhr.onerror = ->
      console.log("XHR ERROR")
      return

    xhr.send()

And the following Ruby on Rails code server-side:

    config.middleware.insert(0, Rack::ReverseProxy) do
      reverse_proxy_options preserve_host: true
      reverse_proxy '/watch', 'http://youtube.com/'
    end

I'm still getting a CORS error on the client-side. I've been playing with different reverse_proxy_options but couldn't make it work so far.

Is it possible to achieve this with rack-reverse-proxy? Which options should I use?

Thanks for your help

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions