cors issue with next js & fumadocs (CORS Allow Origin Not Matching Origin)
<body>
<RootProvider>{children}</RootProvider>
<script
defer
src="https://domain.something.tld/script.js"
data-website-id="id"
></script>
</body>
I am not familar with next js (only svelte) so sorry if it's a basic question. I was not able to find any working solution. I even added the following in next js config file
headers: async () => {
return [
{
// mathching all API routes
source: "/api/:path*",
headers: [
{ key: "Access-Control-Allow-Credentials", value: "true" },
{ key: "Access-Control-Allow-Origin", value: "*" },
{
key: "Access-Control-Allow-Methods",
value: "GET,OPTIONS,PATCH,DELETE,POST,PUT",
},
{
key: "Access-Control-Allow-Headers",
value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
},
],
},
];
},
8 Replies
wiki/app/layout.tsx
export default function Layout({ children }: { children: ReactNode }) {
return (
<html lang="en" className={inter.className} suppressHydrationWarning>
<body>
<RootProvider>{children}</RootProvider>
<script
defer
src="https://analytics.domain.tld/script.js"
data-website-id="id"
></script>
</body>
</html>
);
}