Skip to content

Commit 82494d6

Browse files
justin808claude
andcommitted
Add configuration options for secure server bundle management
Introduces two new configuration options to enhance server bundle path resolution and security: - server_bundle_output_path: Configurable directory for server bundle output (defaults to "ssr-generated") - enforce_secure_server_bundles: Optional security enforcement for server bundle loading (defaults to false for backward compatibility) These options work in conjunction with the existing bundle path resolution improvements to provide better organization and security for server-side rendering assets. Features: - Secure server bundle location configuration - Backward compatibility maintained with sensible defaults - Comprehensive documentation added to configuration guide - Full parameter support in Configuration class initialization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2ea74d9 commit 82494d6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

docs/guides/configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ 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+
# Directory where server bundles will be output during build process.
133+
# This allows organizing server-side rendering assets separately from client assets.
134+
# Default is "ssr-generated"
135+
config.server_bundle_output_path = "ssr-generated"
136+
137+
# When enabled, enforces that server bundles are only loaded from secure, designated locations
138+
# to prevent potential security risks from loading untrusted server-side code.
139+
# Default is false for backward compatibility.
140+
config.enforce_secure_server_bundles = false
141+
132142
# `prerender` means server-side rendering
133143
# default is false. This is an option for view helpers `render_component` and `render_component_hash`.
134144
# Set to true to change the default value to true.

lib/react_on_rails/configuration.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def self.configuration
5252
# If exceeded, an error will be thrown for server-side rendered components not registered on the client.
5353
# Set to 0 to disable the timeout and wait indefinitely for component registration.
5454
component_registry_timeout: DEFAULT_COMPONENT_REGISTRY_TIMEOUT,
55-
generated_component_packs_loading_strategy: nil
55+
generated_component_packs_loading_strategy: nil,
56+
server_bundle_output_path: "ssr-generated",
57+
enforce_secure_server_bundles: false
5658
)
5759
end
5860

@@ -68,7 +70,8 @@ class Configuration
6870
:same_bundle_for_client_and_server, :rendering_props_extension,
6971
:make_generated_server_bundle_the_entrypoint,
7072
:generated_component_packs_loading_strategy, :immediate_hydration, :rsc_bundle_js_file,
71-
:react_client_manifest_file, :react_server_client_manifest_file, :component_registry_timeout
73+
:react_client_manifest_file, :react_server_client_manifest_file, :component_registry_timeout,
74+
:server_bundle_output_path, :enforce_secure_server_bundles
7275

7376
# rubocop:disable Metrics/AbcSize
7477
def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
@@ -85,7 +88,7 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender
8588
random_dom_id: nil, server_render_method: nil, rendering_props_extension: nil,
8689
components_subdirectory: nil, auto_load_bundle: nil, immediate_hydration: nil,
8790
rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil,
88-
component_registry_timeout: nil)
91+
component_registry_timeout: nil, server_bundle_output_path: nil, enforce_secure_server_bundles: nil)
8992
self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
9093
self.generated_assets_dirs = generated_assets_dirs
9194
self.generated_assets_dir = generated_assets_dir
@@ -130,6 +133,8 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender
130133
self.defer_generated_component_packs = defer_generated_component_packs
131134
self.immediate_hydration = immediate_hydration
132135
self.generated_component_packs_loading_strategy = generated_component_packs_loading_strategy
136+
self.server_bundle_output_path = server_bundle_output_path
137+
self.enforce_secure_server_bundles = enforce_secure_server_bundles
133138
end
134139
# rubocop:enable Metrics/AbcSize
135140

0 commit comments

Comments
 (0)