Replies: 2 comments 1 reply
-
|
FYI, commit 45d165749 (April 8) confirms the team is aware of the exact CORS+Active Storage pattern we're hitting. That fix was specifically for development with MinIO. The production self-hosted case with S3-compatible storage on a different domain is still broken. |
Beta Was this translation helpful? Give feedback.
-
|
@puffo Sorry for not responding sooner. If you'd like to open a pull request that adds/removes the CORS option from Or, if you've already opened a pull request, tag me and I'll review. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone! I think I may have picked up a problem with the fairly recent changes to the service workers behaviour related to fetching Rails active storage variants.
Problem
Inline images in comments/cards return "FetchEvent.respondWith received an error: Returned response is null" on self-hosted instances using S3-compatible storage (Hetzner Object Storage in my case). Clicking images to download them works fine, only inline rendering is broken.
Root Cause
The service worker rule for Active Storage (
service_worker.js.erb:38-48) usesfetchOptions: { mode: "cors" }:This was added in commit 9a86c7cb with the note: "The load balancer now returns a specific
Access-Control-Allow-Origininstead of a wildcard." This works on 37signals' SaaS infrastructure where the load balancer injects CORS headers on the 302 redirect response.On self-hosted/Once instances there is no load balancer — requests go directly through kamal-proxy, which doesn't inject CORS headers and has no configuration option (as far as I'm aware) to do so. The flow is:
mode: "cors"Access-Control-Allow-Originheader (no load balancer to add it, and kamal-proxy doesn't support custom response headers — see kamal-proxy#62)nullon Webkit browsers, and a more explicit "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." in Chrome browsers.FetchEvent.respondWithfailsVerification
Environment
basecamp/kamal-proxy:once-01) — no load balancer in frontPossible Fixes
mode: "cors"behindFizzy.saas?in the service worker templatemode: "cors")Ideally, it'd be best to keep the extra
maxEntrySizeenforcement and avoid reverting to thecredentials: "omit"approach, but I'm curious for whether this is a problem for others and what the best way to fix it might be?Beta Was this translation helpful? Give feedback.
All reactions