My frontend app is running on http://localhost:8080
My backend app (Rails) is running on http://localhost:3000. This is an API app
Setting cors like below:
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'http://localhost:8080'
resource '*',
headers: :any,
methods: %i[get post put patch delete options],
credentials: true,
expose: ['Set-Cookie']
end
end
Context:
http://localhost:8080
http://localhost:3000
. This is an API appSetting cors like below:
withCredentials
true that assign value to thesession
e.g.session[:user_id] = user.id
Current behavior: The response header contains the
Set-Cookie
:But the browser does not store it in the Storage cookies
Expected behavior: The browser stores it in the Storage cookies