-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(clerk-js): Send FAPI version through URLSearchParams #4457
base: main
Are you sure you want to change the base?
Changes from all commits
f577cb8
b9b7184
82d0dfe
93fe983
687aa1d
0f9ab2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
--- | ||
|
||
Now sending the Frontend API version through query string params |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { runWithExponentialBackOff } from '@clerk/shared/utils'; | |
import type { Clerk, ClerkAPIErrorJSON, ClientJSON } from '@clerk/types'; | ||
|
||
import { buildEmailAddress as buildEmailAddressUtil, buildURL as buildUrlUtil, stringifyQueryParams } from '../utils'; | ||
import { SUPPORTED_FAPI_VERSION } from './constants'; | ||
import { clerkNetworkError } from './errors'; | ||
|
||
export type HTTPMethod = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE'; | ||
|
@@ -93,6 +94,9 @@ export function createFapiClient(clerkInstance: Clerk): FapiClient { | |
const searchParams = new URLSearchParams(search as any); | ||
// the above will parse {key: ['val1','val2']} as key: 'val1,val2' and we need to recreate the array bellow | ||
|
||
// Append supported FAPI version to the query string | ||
searchParams.append('__clerk_api_version', SUPPORTED_FAPI_VERSION); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one for clerk js version only has one underscore as a prefix, is there a reason we break out of the existing pattern ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question. Following the docs here: https://clerk.com/docs/backend-requests/versioning/overview#choosing-an-api-version . I can confirm with the API team that the double underscore is expected |
||
|
||
if (clerkInstance.version) { | ||
searchParams.append('_clerk_js_version', clerkInstance.version); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about FAPI versioning and keeping types in sync. The types package version and which FAPI version they represent.