fix: authedFetch URL resolution breaks when DENO_DEPLOY_ENDPOINT contains a path#82
Open
uriva wants to merge 4 commits intodenoland:mainfrom
Open
fix: authedFetch URL resolution breaks when DENO_DEPLOY_ENDPOINT contains a path#82uriva wants to merge 4 commits intodenoland:mainfrom
uriva wants to merge 4 commits intodenoland:mainfrom
Conversation
d930f92 to
496509a
Compare
Include the generated lib/snippets/sys_traits-4d1fdc43f822dba1/inline0.js file that rs_lib.internal.js imports at runtime. Without it, the CLI fails before any Deno Deploy request is made with a module-not-found error.
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.
Problem
When
DENO_DEPLOY_ENDPOINTcontains a path component (e.g.https://proxy.example.com/deno), theauthedFetchfunction inauth.tsconstructs an incorrect URL.The current code uses:
Where
endpointis a relative path like"api/diffsync/org/app/revisionId". Thenew URL()two-argument form treats the last path segment of the base as a filename and resolves relative to its parent directory. So with basehttps://proxy.example.com/deno:The
/denopath segment is dropped entirely.Note: The tRPC client in the same file does not have this issue because it uses string concatenation:
context.endpoint + "/api".Fix
Use string concatenation to match the tRPC client pattern:
Also added a defensive
String()coercion inutil.ts'serror()function. WhenauthedFetchcallers pass an error response body's.messagefield, it can beundefinedif the upstream returns an unexpected response shape — causing.replaceAll()to crash with"Cannot read properties of undefined".Changes
auth.ts: Replacenew URL(endpoint, context.endpoint)withnew URL(\${context.endpoint}/${endpoint}`)`util.ts: Wraperrorparameter withString(error ?? "Unknown error")before calling.replaceAll()