In my domain with Render I use this URL rewrite
www.example.com/library to library.example.com
This works as expected, so if the user visits example.com/library the content is server from a subdomain. The CSS is loaded as expected but I got a CORS error only for JS.
From the dev console, when visiting example.com/library I see
CORS ERROR
GET https://library.example.com/assets/application-ec9fb8976583666f9882e99ffe94f0391fc9ac4f1a32034d128201c87ac33ca3.js
Request headers
- sec-fetch-dest: script
- sec-fetch-mode: cors
- sec-fetch-site: same-site
- Origin: https://www.example.com
/config/application.rb
config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'https://www.example.com'
resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
but isn’t working.
I expect no errors in dev console and I must be able to visit example.com/library and load the page served from library.example.com with all CSS and JS.
2