Skip to content

Commit 994cb73

Browse files
authored
Merge pull request #445 from skip-mev/feat(middleware)/-add-trycloudflare-to-preview
Feat(middleware)/ add trycloudflare to preview
2 parents cb51270 + cd623b2 commit 994cb73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const cleanOrigin = (str: string) => {
1919

2020
return domain;
2121
} catch (error) {
22+
console.error("error", error);
2223
return str; // Return the original string if it's not a valid URL
2324
}
2425
};
@@ -38,7 +39,7 @@ const isNetlifyPreview = (str: string) => {
3839
};
3940

4041
const isCloudflarePreview = (str: string) => {
41-
if (str.endsWith("pages.dev")) {
42+
if (str.endsWith("pages.dev") || "trycloudflare.com") {
4243
return true;
4344
}
4445
return false;
@@ -94,6 +95,7 @@ const corsMiddleware = async (request: NextRequest, response: NextResponse) => {
9495
const allowedOrigins = await stringArraySchema.parseAsync(allowedOriginsData);
9596
return allowedOrigins.includes(domain);
9697
})();
98+
9799
// Handle preflighted requests
98100
const isPreflight = request.method === "OPTIONS";
99101
if (isPreflight) {

0 commit comments

Comments
 (0)