mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Replace all usage of getPublishedContentByUrl (#3395)
This commit is contained in:
@@ -14,7 +14,7 @@ export type RouteLayoutParams = {
|
||||
/** URL encoded site URL */
|
||||
siteURL: string;
|
||||
|
||||
/** URL and Rison encoded site data from getPublishedContentByUrl */
|
||||
/** URL and Rison encoded site data from resolvePublishedContentByUrl */
|
||||
siteData: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { jwtDecode } from 'jwt-decode';
|
||||
export type VisitorAuthClaims = Record<string, any>;
|
||||
|
||||
/**
|
||||
* Get the visitor auth claims from the API response obtained from `getPublishedContentByUrl`.
|
||||
* Get the visitor auth claims from the API response obtained from `resolvePublishedContentByUrl`.
|
||||
*/
|
||||
export function getVisitorAuthClaims(siteData: SiteURLData): VisitorAuthClaims {
|
||||
const { apiToken } = siteData;
|
||||
|
||||
@@ -131,7 +131,7 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
|
||||
jwtToken: visitorToken?.token ?? undefined,
|
||||
unsignedClaims,
|
||||
},
|
||||
// When the visitor auth token is pulled from the cookie, set redirectOnError when calling getPublishedContentByUrl to allow
|
||||
// When the visitor auth token is pulled from the cookie, set redirectOnError when calling resolvePublishedContentByUrl to allow
|
||||
// redirecting when the token is invalid as we could be dealing with stale token stored in the cookie.
|
||||
// For example when the VA backend signature has changed but the token stored in the cookie is not yet expired.
|
||||
redirectOnError: visitorToken?.source === 'visitor-auth-cookie',
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function getSiteAPIToken(url: string) {
|
||||
const api = new GitBookAPI({
|
||||
endpoint: 'https://api.gitbook.com/cache',
|
||||
});
|
||||
const { data } = await api.urls.getPublishedContentByUrl({
|
||||
const { data } = await api.urls.resolvePublishedContentByUrl({
|
||||
url,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user