Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: relative URL is being used where an absolute URL is required #20314

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anikdhabal
Copy link
Contributor

No description provided.

@graphite-app graphite-app bot requested a review from a team March 22, 2025 09:55
Copy link

vercel bot commented Mar 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 24, 2025 2:36pm
calcom-web-canary 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 24, 2025 2:36pm

@keithwillcode keithwillcode added the core area: core, team members only label Mar 22, 2025
}

await prisma.booking.update({
where: { id: booking.id },
data: { oneTimePassword: null },
});

return NextResponse.redirect(`/booking/${booking.uid}`);
return NextResponse.redirect(`${url.origin}/booking/${booking.uid}`);
Copy link
Contributor Author

@anikdhabal anikdhabal Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A relative URL (/booking/nhyUM5U2KVsyuxxxxxxxxx) is being used where an absolute URL is required in redirect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is the case, we better construct a full url in middleware so we prevent bugs for all other cases of redirect usages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, isn't this no-relative-url rule specific to middleware function only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anikdhabal This is not a middleware. It's an API route. Can we confirm this is a valid fix with evidence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is not middleware. Sorry for the wrong title. But there's still an error here because NextResponse.redirect() requires an absolute URL, and we passed a relative URL.

Currently, due to this, we are getting this error: -Error:%20URL%20is%20malformed%20"/booking/cZP4p2eYbdd7Pptm3v1Y8N".%20Please%20use%20only%20absolute%20URLs%20-%20https://nextjs.org/docs/messages/middleware-relative-urls

Copy link
Contributor Author

@anikdhabal anikdhabal Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zomars I've tested it, and it's working fine. As we can see in this file, we already perform the correct redirection, but these places were missing it.
For eg:-

`${url.origin}/booking/${bookingUid}?error=${encodeURIComponent("Error confirming booking")}`

@anikdhabal anikdhabal changed the title fix: organizer req email v2 redirect issue fix: relative URL is being used where an absolute URL is required in middleware Mar 22, 2025
@anikdhabal anikdhabal changed the title fix: relative URL is being used where an absolute URL is required in middleware fix: relative URL is being used where an absolute URL is required in middleware Mar 22, 2025
Copy link

graphite-app bot commented Mar 22, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (03/22/25)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment

@github-actions github-actions bot marked this pull request as draft March 23, 2025 18:22
@anikdhabal anikdhabal changed the title fix: relative URL is being used where an absolute URL is required in middleware fix: relative URL is being used where an absolute URL is required Mar 24, 2025
@anikdhabal anikdhabal requested review from zomars and hbjORbj March 24, 2025 06:56
@anikdhabal anikdhabal marked this pull request as ready for review March 24, 2025 07:03
@dosubot dosubot bot added the 🐛 bug Something isn't working label Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working core area: core, team members only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants