Serve app shell directly instead of JS-redirect via cookie#2707
Merged
Conversation
Deep links to docs and the static pages (settings, offline, about, news, help) previously bounced through `/` with a short-lived `initial_path` cookie that the client read back to restore the path. This removes that detour: the server now renders the app shell (erb :index / erb :other) directly at the requested URL, and page.js dispatches location.pathname on start(). This is behaviour that already shipped for docs a user hadn't enabled; enabled docs and the static pages now take the same path. The offline story is unaffected — the service worker already falls back to the cached `/` for non-asset paths when the network fails. Removes the `initial_path` cookie, the redirect_via_js / supports_js_redirection? / modern_browser? helpers, and the client-side getInitialPathFromCookie. The hash-based initial-path handling (used by /search and legacy /#/ bookmarks) is untouched.
There was a problem hiding this comment.
Pull request overview
This PR removes the initial_path cookie + JS-redirect “bounce through /” and instead serves the SPA app shell directly at deep-link URLs (docs paths and static pages like settings/offline/about/news/help). This aligns enabled-doc behavior with the already-shipped behavior for users without enabled docs, while keeping existing hash-based initial-path handling intact.
Changes:
- Serve
erb :indexdirectly for static pages (/settings,/offline,/about,/news,/help) instead of redirecting to/#/...or via theinitial_pathcookie. - Serve
erb :otherdirectly for enabled docs URLs instead of redirecting to/withinitial_path. - Remove client-side
getInitialPathFromCookie()handling from the router.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
test/app_test.rb |
Updates expectations from redirects + initial_path cookie to direct 200 responses for static pages and enabled docs. |
lib/app.rb |
Removes JS-redirection helpers and switches static page + doc handling to render app shell directly at requested URLs. |
assets/javascripts/app/router.js |
Drops cookie-based initial-path restoration; keeps hash-based handling for legacy /#/ entry points. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert_equal 'https://example.org/', last_response['Location'] | ||
| assert last_response['Set-Cookie'].start_with?("initial_path=%2F#{page}; path=/; expires=") | ||
| assert last_response.ok? | ||
| assert_nil last_response['Set-Cookie'] |
| assert_equal 'https://example.org/', last_response['Location'] | ||
| assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=") | ||
| assert last_response.ok? | ||
| assert_nil last_response['Set-Cookie'] |
| assert_equal 'https://example.org/', last_response['Location'] | ||
| assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%2F; path=/; expires=") | ||
| assert last_response.ok? | ||
| assert_nil last_response['Set-Cookie'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deep links to docs and the static pages (settings, offline, about, news, help) previously bounced through
/with a short-livedinitial_pathcookie that the client read back to restore the path. This removes that detour: the server now renders the app shell (erb :index / erb :other) directly at the requested URL, and page.js dispatches location.pathname on start().This is behaviour that already shipped for docs a user hadn't enabled; enabled docs and the static pages now take the same path. The offline story is unaffected — the service worker already falls back to the cached
/for non-asset paths when the network fails.Removes the
initial_pathcookie, the redirect_via_js / supports_js_redirection? / modern_browser? helpers, and the client-side getInitialPathFromCookie. The hash-based initial-path handling (used by /search and legacy /#/ bookmarks) is untouched.