Skip to content
Merged
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
17 changes: 17 additions & 0 deletions app/javascript/controllers/strip_url_credentials_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Controller } from "@hotwired/stimulus"

// Strips HTTP Basic-Auth credentials from the URL (e.g. https://user:pass@host).
// The user:pass@ form makes document.URL mismatch the credential-free URL Turbo
// passes to history.replaceState(), throwing a SecurityError that breaks the page.
// The browser has already cached the credentials, so the clean navigation below
// stays authenticated.
export default class extends Controller {
connect() {
const url = new URL(window.location.href)
if (url.username || url.password) {
url.username = ""
url.password = ""
window.location.replace(url.toString())
}
}
}
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<%= javascript_importmap_tags %>
</head>

<body class="min-h-screen bg-canvas">
<body class="min-h-screen bg-canvas" data-controller="strip-url-credentials">
<nav class="sticky top-0 z-50 flex h-13 items-center border-b border-line bg-surface px-6 sm:px-9">
<%= link_to(authenticated? ? dashboard_path : root_path, class: "flex items-center gap-2 font-serif text-lg tracking-tight text-ink hover:text-ink") do %>
<% if Current.organization&.logo&.attached? %>
Expand Down
Loading