mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Move ~scalar/proxy route to site route group (#4083)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gitbook/react-openapi": patch
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Move ~scalar/proxy route to site route group
|
||||
@@ -32,8 +32,11 @@ export function getOpenAPIContext(args: {
|
||||
const customizationLocale = context ? getSpaceLocale(context) : DEFAULT_LOCALE;
|
||||
const locale = checkIsValidLocale(customizationLocale) ? customizationLocale : DEFAULT_LOCALE;
|
||||
|
||||
const proxyUrl = context ? context.linker.toPathInSite('~scalar/proxy') : undefined;
|
||||
|
||||
return {
|
||||
specUrl,
|
||||
proxyUrl,
|
||||
icons: {
|
||||
chevronDown: <Icon icon="chevron-down" />,
|
||||
chevronRight: <Icon icon="chevron-right" />,
|
||||
|
||||
@@ -36,7 +36,7 @@ import { getPreviewRequestIdentifier } from './lib/preview';
|
||||
import { serveProxyAnalyticsEvent } from './lib/tracking';
|
||||
export const config = {
|
||||
matcher: [
|
||||
'/((?!_next/static|_next/image|~gitbook/static|~gitbook/revalidate|~gitbook/monitoring|~scalar/proxy).*)',
|
||||
'/((?!_next/static|_next/image|~gitbook/static|~gitbook/revalidate|~gitbook/monitoring).*)',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -663,6 +663,7 @@ function encodePathInSiteContent(
|
||||
return { pathname, routeType: 'static' };
|
||||
case '~gitbook/pdf':
|
||||
case '~gitbook/search':
|
||||
case '~scalar/proxy':
|
||||
// PDF and search routes are always dynamic as they depend on the request.
|
||||
return { pathname, routeType: 'dynamic' };
|
||||
default: {
|
||||
|
||||
@@ -53,6 +53,7 @@ export function ScalarApiButton(props: {
|
||||
<ScalarModal
|
||||
controllerRef={controllerRef}
|
||||
withProxy={withProxy}
|
||||
proxyUrl={context.proxyUrl}
|
||||
method={method}
|
||||
path={path}
|
||||
securities={securities}
|
||||
@@ -73,9 +74,11 @@ function ScalarModal(props: {
|
||||
servers: OpenAPIOperationData['servers'];
|
||||
specUrl: string;
|
||||
withProxy: boolean;
|
||||
proxyUrl?: string;
|
||||
controllerRef: React.Ref<ScalarModalControllerRef>;
|
||||
}) {
|
||||
const { method, path, securities, servers, specUrl, withProxy, controllerRef } = props;
|
||||
const { method, path, securities, servers, specUrl, withProxy, proxyUrl, controllerRef } =
|
||||
props;
|
||||
|
||||
const getPrefillInputContextData = useOpenAPIPrefillContext();
|
||||
const prefillInputContext = getPrefillInputContextData();
|
||||
@@ -90,7 +93,7 @@ function ScalarModal(props: {
|
||||
configuration={{
|
||||
url: specUrl,
|
||||
...prefillConfig,
|
||||
proxyUrl: withProxy ? '/~scalar/proxy' : undefined,
|
||||
proxyUrl: withProxy ? proxyUrl : undefined,
|
||||
}}
|
||||
initialRequest={{ method: toScalarHttpMethod(method), path }}
|
||||
>
|
||||
|
||||
@@ -34,6 +34,11 @@ export interface OpenAPIClientContext {
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* The URL for the Scalar proxy endpoint.
|
||||
*/
|
||||
proxyUrl?: string;
|
||||
|
||||
/**
|
||||
* Mark the context as a client context.
|
||||
*/
|
||||
@@ -97,6 +102,7 @@ export function getOpenAPIClientContext(context: OpenAPIUniversalContext): OpenA
|
||||
defaultInteractiveOpened: context.defaultInteractiveOpened,
|
||||
blockKey: context.blockKey,
|
||||
id: context.id,
|
||||
proxyUrl: context.proxyUrl,
|
||||
$$isClientContext$$: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user