Skip to content

Instantly share code, notes, and snippets.

@raelgc
Last active February 4, 2024 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raelgc/799cadce1303bd604a38bc3808d272b4 to your computer and use it in GitHub Desktop.
Save raelgc/799cadce1303bd604a38bc3808d272b4 to your computer and use it in GitHub Desktop.
Rack Cors configuration for Vite
# TODO: Add production URLs to the list
# Use '*' if you want expose the API to the world
accept = [
'http://127.0.0.1:5173', # Dev Frontend
'http://localhost:5173', # Dev Frontend
'http://127.0.0.1:5174', # Dev Frontend
'http://localhost:5174', # Dev Frontend
]
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins accept
resource '*',
headers: :any,
methods: %i[get post put delete options patch],
expose: %w[Authorization]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment