From d344256013594c48c57864d86456b6f1b0b605c2 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Mon, 6 Apr 2020 00:01:11 +0200 Subject: [PATCH] Configure CORS headers for submission endpoint --- Gemfile | 1 + Gemfile.lock | 3 +++ config/application.rb | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index 9e8b9d5..001fc06 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ gem 'jbuilder' gem 'bootsnap', '>= 1.4.2', require: false gem 'google-api-client' +gem 'rack-cors' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index d103d43..351b156 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -121,6 +121,8 @@ GEM puma (4.3.3) nio4r (~> 2.0) rack (2.2.2) + rack-cors (1.1.1) + rack (>= 2.0.0) rack-proxy (0.6.5) rack rack-test (1.1.0) @@ -217,6 +219,7 @@ DEPENDENCIES listen pg puma + rack-cors rails sass-rails spring diff --git a/config/application.rb b/config/application.rb index c25598f..2dae959 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,5 +15,11 @@ module Tinyform # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. + config.middleware.insert_before 0, Rack::Cors do + allow do + origins '*' + resource '/s/*', headers: :any, methods: [:post, :put, :options] + end + end end end