mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-12 13:18:43 -05:00
ops: more changes for cors for docs (#1816)
* changes * lint * fix dynamic url
This commit is contained in:
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user