How to set CORS origin

in Google App Engine for Ruby Project

Hash tags: CORS Google App Engine API

It took me some time to figure and I can say that there is no way to set CORS origins in google UI. So we will have to install gem inside our API project and deploy changes to google cloud:

  1. Add gem 'rack-cors' to gem file
  2. Bundle install
  3. Add following to application.rb:
config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '*'
    resource '*', headers: :any, methods: :any
  end
end

Don't forget to update '*'  before deploying to production.

PROJECTS


MORE BLOGS