Skip to content

Commit 870835f

Browse files
justin808claude
andcommitted
Enhance documentation: crystal clear changelog and configuration guide
CHANGELOG.md: - Document all new server bundle security features - Explain enhanced bundle path resolution with fallback logic - Document public_bundles_full_path method naming improvement - Clear categorization: New Features, API Improvements, Security Enhancements, Bug Fixes docs/guides/configuration.md: - Add comprehensive SERVER BUNDLE SECURITY AND ORGANIZATION section - Document server_bundle_output_path with clear examples and defaults - Explain enforce_private_server_bundles with security implications - Add BUNDLE ORGANIZATION EXAMPLES section with: * Clear client vs server bundle separation * Directory structure examples * API method references (public_bundles_full_path vs server_bundle_js_file_path) This documentation makes the new features crystal clear for users upgrading or configuring server bundle security for the first time. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 349e334 commit 870835f

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,34 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
2323

2424
Changes since the last non-beta release.
2525

26+
#### New Features
27+
28+
- **Server Bundle Security**: Added new configuration options for enhanced server bundle security and organization:
29+
- `server_bundle_output_path`: Configurable directory for server bundle output (default: nil, uses fallback locations)
30+
- `enforce_private_server_bundles`: When enabled, ensures server bundles are only loaded from private directories outside the public folder (default: false for backward compatibility)
31+
32+
- **Improved Bundle Path Resolution**: Enhanced bundle path resolution with better fallback logic that tries multiple locations when manifest lookup fails:
33+
1. Environment-specific path (e.g., `public/webpack/test`)
34+
2. Standard Shakapacker location (`public/packs`)
35+
3. Generated assets path (for legacy setups)
36+
37+
#### API Improvements
38+
39+
- **Method Naming Clarification**: Added `public_bundles_full_path` method to clarify bundle path handling:
40+
- `public_bundles_full_path`: New method specifically for webpack bundles in public directories
41+
- `generated_assets_full_path`: Now deprecated (backwards-compatible alias)
42+
- This eliminates confusion between webpack bundles and general Rails public assets
43+
44+
#### Security Enhancements
45+
46+
- **Private Server Bundle Enforcement**: When `enforce_private_server_bundles` is enabled, server bundles bypass public directory fallbacks and are only loaded from designated private locations
47+
- **Path Validation**: Added validation to ensure `server_bundle_output_path` points to private directories when enforcement is enabled
48+
49+
#### Bug Fixes
50+
51+
- **Non-Packer Environment Compatibility**: Fixed potential NoMethodError when using bundle path resolution in environments without Shakapacker
52+
- **Server Bundle Detection**: Improved server bundle detection to work correctly with both `server_bundle_js_file` and `rsc_bundle_js_file` configurations
53+
2654
### [16.0.1-rc.2] - 2025-09-20
2755

2856
#### Bug Fixes

docs/guides/configuration.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,69 @@ ReactOnRails.configure do |config|
129129
# This manifest file is automatically generated by the React Server Components Webpack plugin. Only set this if you've configured the plugin to use a different filename.
130130
config.react_server_client_manifest_file = "react-server-client-manifest.json"
131131

132+
################################################################################
133+
# SERVER BUNDLE SECURITY AND ORGANIZATION
134+
################################################################################
135+
132136
# Directory where server bundles will be output during build process.
133137
# This allows organizing server-side rendering assets separately from client assets.
134-
# Default is nil (uses standard fallback locations). Set to "ssr-generated" or your preferred directory path.
135-
# config.server_bundle_output_path = "ssr-generated"
138+
#
139+
# Default is nil, which uses standard fallback locations in this priority order:
140+
# 1. Environment-specific path (e.g., public/webpack/test)
141+
# 2. Standard Shakapacker location (public/packs)
142+
# 3. Generated assets path (for legacy setups)
143+
#
144+
# Example configurations:
145+
# config.server_bundle_output_path = "ssr-generated" # Private directory (recommended)
146+
# config.server_bundle_output_path = "app/assets/builds" # Custom private location
147+
# config.server_bundle_output_path = nil # Use fallback locations (default)
148+
config.server_bundle_output_path = nil
136149

137150
# When enabled, enforces that server bundles are only loaded from private, designated locations
138151
# to prevent potential security risks from loading untrusted server-side code.
139-
# When enabled, server_bundle_output_path must point to a private location outside the public directory.
152+
#
153+
# SECURITY IMPORTANT: When enabled, server bundles bypass public directory fallbacks
154+
# and are only loaded from the configured server_bundle_output_path.
155+
#
156+
# Requirements when enabled:
157+
# - server_bundle_output_path must be set to a non-nil value
158+
# - server_bundle_output_path must point to a location outside the public directory
159+
# - Recommended for production environments where security is critical
160+
#
140161
# Default is false for backward compatibility.
141162
config.enforce_private_server_bundles = false
142163

164+
################################################################################
165+
# BUNDLE ORGANIZATION EXAMPLES
166+
################################################################################
167+
#
168+
# This configuration creates a clear separation between client and server assets:
169+
#
170+
# CLIENT BUNDLES (Public, Web-Accessible):
171+
# Location: public/webpack/[environment]/ or public/packs/
172+
# Files: application.js, manifest.json, CSS files
173+
# Served by: Web server directly
174+
# Access: ReactOnRails::Utils.public_bundles_full_path
175+
#
176+
# SERVER BUNDLES (Private, Server-Only):
177+
# Location: ssr-generated/ (when server_bundle_output_path configured)
178+
# Files: server-bundle.js, rsc-bundle.js
179+
# Served by: Never served to browsers
180+
# Access: ReactOnRails::Utils.server_bundle_js_file_path
181+
#
182+
# Example directory structure with recommended configuration:
183+
# app/
184+
# ├── ssr-generated/ # Private server bundles
185+
# │ ├── server-bundle.js
186+
# │ └── rsc-bundle.js
187+
# └── public/
188+
# └── webpack/development/ # Public client bundles
189+
# ├── application.js
190+
# ├── manifest.json
191+
# └── styles.css
192+
#
193+
################################################################################
194+
143195
# `prerender` means server-side rendering
144196
# default is false. This is an option for view helpers `render_component` and `render_component_hash`.
145197
# Set to true to change the default value to true.

0 commit comments

Comments
 (0)