Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/pwa/service_worker.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TurboOffline.addRule({
networkTimeout: 2,
maxEntrySize: 2 * 1024 * 1024, // 2MB covers about 95% of all Fizzy blobs
maxEntries: 500,
fetchOptions: { mode: "cors" }
fetchOptions: { mode: "cors", credentials: "same-origin" }
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is subtle but security/CORS-sensitive (it intentionally strips credentials on cross-origin redirects). Adding an inline comment explaining the redirect/CORS rationale here would help prevent future regressions (e.g., someone reverting to include while debugging auth).

Suggested change
fetchOptions: { mode: "cors", credentials: "same-origin" }
fetchOptions: {
mode: "cors",
// Intentionally avoid `include`: with CORS requests, `same-origin` strips
// credentials on cross-origin redirects, which is the safer behavior here.
credentials: "same-origin"
}

Copilot uses AI. Check for mistakes.
})
})

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/active_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Ensure all <action-text-attachment>s have a "url" attribute that's a relative
# path (for portability across host name changes, beta environments, etc).
def to_rich_text_attributes(*)
super.merge url: Rails.application.routes.url_helpers.polymorphic_url(self, only_path: true)
super.merge url: Rails.application.routes.url_helpers.polymorphic_url(self, only_path: true, script_name: Current.account&.slug)
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script_name is expected to be a path prefix (typically starting with /). Passing a bare slug (e.g., \"123\") can produce malformed paths (missing separator) depending on how Rails concatenates script_name + path. Consider normalizing to script_name: \"/#{Current.account.slug}\" (or using a helper that already returns a leading-slash prefix) so generated URLs are reliably /123/....

Suggested change
super.merge url: Rails.application.routes.url_helpers.polymorphic_url(self, only_path: true, script_name: Current.account&.slug)
slug = Current.account&.slug
super.merge url: Rails.application.routes.url_helpers.polymorphic_url(
self,
only_path: true,
script_name: (slug.present? ? "/#{slug.delete_prefix("/")}" : nil)
)

Copilot uses AI. Check for mistakes.
end
end
end
Expand Down
Loading