File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9393 "handlebars" : " ^4.7.7" ,
9494 "ical.js" : " ^1.4.0" ,
9595 "ics" : " ^2.37.0" ,
96+ "isbot" : " ^5.1.30" ,
9697 "jose" : " ^4.13.1" ,
9798 "jotai" : " ^2.12.2" ,
9899 "jsdom" : " ^22.0.0" ,
Original file line number Diff line number Diff line change 11import { wrapGetServerSidePropsWithSentry } from "@sentry/nextjs" ;
2+ import { isbot } from "isbot" ;
23import type { GetServerSidePropsContext } from "next" ;
34
45import { getRoutedUrl , hasEmbedPath } from "@calcom/features/routing-forms/lib/getRoutedUrl" ;
6+ import logger from "@calcom/lib/logger" ;
57
68import { TRPCError } from "@trpc/server" ;
79
10+ const log = logger . getSubLogger ( { prefix : [ "router/getServerSideProps" ] } ) ;
11+
12+ // Show a positive message to the bots so that they don't think that the form is broken.
13+ const BOT_MESSAGE = "Thank you for your interest! We will be in touch soon." ;
14+
815export const getServerSideProps = wrapGetServerSidePropsWithSentry ( async function getServerSideProps (
916 context : GetServerSidePropsContext
1017) {
1118 try {
19+ // Check if the request is from a bot
20+ const userAgent = context . req . headers [ "user-agent" ] ;
21+ if ( userAgent && isbot ( userAgent ) ) {
22+ log . info ( `[BOT] Ignoring request from user agent: ${ userAgent } ` ) ;
23+ return {
24+ props : {
25+ isEmbed : hasEmbedPath ( context . req . url || "" ) ,
26+ form : null ,
27+ message : BOT_MESSAGE ,
28+ errorMessage : null ,
29+ } ,
30+ } ;
31+ }
32+
1233 return await getRoutedUrl ( context ) ;
1334 } catch ( error ) {
1435 if ( error instanceof TRPCError && error . code === "TOO_MANY_REQUESTS" ) {
Original file line number Diff line number Diff line change @@ -4307,6 +4307,7 @@ __metadata:
43074307 handlebars: ^4.7.7
43084308 ical.js: ^1.4.0
43094309 ics: ^2.37.0
4310+ isbot: ^5.1.30
43104311 jose: ^4.13.1
43114312 jotai: ^2.12.2
43124313 jsdom: ^22.0.0
@@ -31899,6 +31900,13 @@ __metadata:
3189931900 languageName: node
3190031901 linkType: hard
3190131902
31903+ "isbot@npm:^5.1.30":
31904+ version: 5.1.30
31905+ resolution: "isbot@npm:5.1.30"
31906+ checksum: 296e6c13767d0d0cff22f778aa8e06fddf59eb347ed0c237647f9a65fd0681fd420468cc9e145f4c9fe7b9d17784816f4991d0299b1f3d489822c0d5c773d264
31907+ languageName: node
31908+ linkType: hard
31909+
3190231910"isbuffer@npm:~0.0.0":
3190331911 version: 0.0.0
3190431912 resolution: "isbuffer@npm:0.0.0"
You can’t perform that action at this time.
0 commit comments