Fix Lens share URLs stripped by SEO redirects#35
Merged
Conversation
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.
Summary
Hotfix for shared Lens viewpoint URLs broken by the SEO redirect logic in #34.
After #34 deployed, links like
/lens/?c=55.36…&m=tl&d=nao…loaded the default map position instead of the shared view. The redirect middleware was stripping all query parameters to canonicalise tracking URLs (?ref=neveroff.dev), but Lens uses the same query string for app state (c,m,d,t,b,y,cy).This PR narrows redirects to tracking params only and preserves Lens state when adding the trailing slash.
Changes
lens/src/server.mjsref,utm_*)/lens?c=…→/lens/?c=…(preserve viewpoint params)/lens/?ref=…→/lens/(strip tracking only)/lens/with Lens state params → 200, no redirectlens/src/index.tsdas well asl(share links generated bymap.tsused, but startup only readl)Context
Follow-up to #33 (SEO migration) and #34 (redirect loop fix). Canonical tag on
/lens/still handles SEO consolidation for any stray tracking URLs Google has already seen.Test plan
curl -s -o /dev/null -w "%{http_code}" 'http://localhost:3939/lens/?c=55.364712,-3.529857,8.32,25&m=tl&d=nao&t=o&b=l&y=2022&cy=2022'→ 200curl -sI 'http://localhost:3939/lens/?ref=neveroff.dev'→ 301 →/lens/curl -sI 'http://localhost:3939/lens?c=55.36…'→ 301 →/lens/?c=55.36…(params preserved)https://weeforest.org/lens/?c=55.364712,-3.529857,8.32,25&m=tl&d=nao&t=o&b=l&y=2022&cy=2022loads correct viewhttps://weeforest.org/lens/?ref=neveroff.devstill redirects to/lens/