ops: more changes for cors for docs (#1816)

* changes

* lint

* fix dynamic url
This commit is contained in:
Gabe Ruttner
2025-06-04 13:55:20 -07:00
committed by GitHub
parent 125789eeab
commit 08896e55ed
2 changed files with 12 additions and 2 deletions
@@ -9,6 +9,7 @@ import {
TooltipTrigger,
} from './tooltip';
import { useSidePanel } from '@/next/hooks/use-side-panel';
import useApiMeta from '@/next/hooks/use-api-meta';
export type DocRef = {
title: string;
@@ -25,6 +26,8 @@ interface DocsButtonProps
titleOverride?: string;
}
// FIXME: this will need to be dynamic for OSS
export const cloudDocsUrl = 'https://docs.onhatchet.run';
export const baseDocsUrl = 'https://docs.hatchet.run';
export function DocsButton({
@@ -37,6 +40,7 @@ export function DocsButton({
...props
}: DocsButtonProps) {
const { close: closeSideSheet, open } = useSidePanel();
const { isCloud } = useApiMeta();
const handleClick = (e: React.MouseEvent) => {
if (method === 'sheet') {
@@ -45,7 +49,7 @@ export function DocsButton({
open({
type: 'docs',
content: {
href: `${baseDocsUrl}${doc.href}`,
href: `${isCloud ? cloudDocsUrl : baseDocsUrl}${doc.href}`,
title: doc.title,
},
});
+7 -1
View File
@@ -36,7 +36,13 @@ export function middleware(request: NextRequest) {
if (isHostAllowed) {
response.headers.set('Access-Control-Allow-Origin', `https://${host}`)
response.headers.set('Access-Control-Allow-Credentials', 'true')
response.headers.set('Cross-Origin-Resource-Policy', 'same-site')
// Set Cross-Origin-Resource-Policy based on the host
if (host.includes('staging.hatchet-tools.com')) {
response.headers.set('Cross-Origin-Resource-Policy', 'cross-origin')
} else {
response.headers.set('Cross-Origin-Resource-Policy', 'same-site')
}
}
return response