Skip to content

Fix section screenshot URLs to use Rails asset_host when available #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

AlanMcCann
Copy link

Summary

This PR fixes 500 errors for section preview images in the Maglev editor when static file serving is disabled in production environments.

Problem

When Rails applications have static file serving disabled (common in production with CDN usage), section screenshot URLs in the Maglev editor fail with 500 errors because they try to serve static assets directly from the application server.

Solution

  • Update FetchSectionScreenshotPath service to check for Rails asset_host configuration
  • Support both string and proc asset_host configurations with proper evaluation
  • Generate full CDN URLs for section screenshots when asset_host is configured
  • Only affects section screenshot/preview images in the editor, not content images

Testing

  • Tested with both string and proc asset_host configurations
  • Verified lazy evaluation for proc-based asset_host
  • Confirmed fix resolves 500 errors in staging environment

This change ensures section preview images work correctly in production environments using CDNs while maintaining backward compatibility.

- Update FetchSectionScreenshotPath to check Rails.application.config.asset_host
- Supports both string and proc asset_host configurations
- Fixes 500 errors for section preview images when static file serving is disabled
- Only affects section screenshot/preview images in the editor
@did
Copy link
Contributor

did commented Aug 22, 2025

implemented here -> #187

Thanks @AlanMcCann

@did did closed this Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants