Add CORS to /message
This commit is contained in:
parent
d7d90f0c91
commit
ca593508c2
@ -11,9 +11,25 @@ class MessagesController < ApplicationController
|
||||
super + [ "completions" ]
|
||||
end
|
||||
|
||||
def cors_set_access_control_headers
|
||||
response.set_header("Access-Control-Allow-Origin", "https://meet.google.com")
|
||||
response.set_header("Access-Control-Allow-Credentials", "true")
|
||||
response.set_header("Access-Control-Allow-Methods", "POST")
|
||||
response.set_header("Access-Control-Allow-Headers", "*")
|
||||
response.set_header("Access-Control-Max-Age", "86400")
|
||||
end
|
||||
|
||||
def cors_preflight_check
|
||||
if request.method == "OPTIONS"
|
||||
cors_set_access_control_headers
|
||||
render plain: ""
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
allow_unauthenticated_access
|
||||
skip_authorization
|
||||
cors_set_access_control_headers
|
||||
|
||||
@message_params = message_params
|
||||
@contest = Contest.find_by_token_for(:token, params[:token])
|
||||
|
@ -24,6 +24,7 @@ Rails.application.routes.draw do
|
||||
resource :session
|
||||
resources :users
|
||||
|
||||
options "message", to: "messages#cors_preflight_check"
|
||||
post "message", to: "messages#create"
|
||||
|
||||
get "public/:id", to: "contests#scoreboard"
|
||||
|
Loading…
x
Reference in New Issue
Block a user