Skip to content

Fix: Replace z.httpUrl() with z.url() for localhost compatibility#249

Open
taheerahmed wants to merge 1 commit intoe2b-dev:mainfrom
taheerahmed:fix/zod-localhost-validation
Open

Fix: Replace z.httpUrl() with z.url() for localhost compatibility#249
taheerahmed wants to merge 1 commit intoe2b-dev:mainfrom
taheerahmed:fix/zod-localhost-validation

Conversation

@taheerahmed
Copy link

Summary

  • Replaces z.httpUrl() with z.url() in the auth confirm route and shared ConfirmEmailInputSchema
  • z.httpUrl() rejects localhost URLs, causing Zod validation errors during local development email verification
  • z.url() validates URL structure while accepting localhost — production URLs (https://e2b.dev/...) continue to pass

Why this is safe

The Zod schema is only responsible for validating that next is a syntactically valid URL. The actual redirect security is handled downstream:

  • isExternalOrigin() checks reject or reroute requests with a different origin
  • buildRedirectUrl() reconstructs the redirect using the dashboard's own origin, only preserving pathname and search params

So switching from z.httpUrl() to z.url() does not weaken security.

Validation

URL z.httpUrl() (before) z.url() (after)
http://localhost:3000/dashboard FAIL PASS
https://e2b.dev/dashboard PASS PASS
not-a-url FAIL FAIL
(empty) FAIL FAIL

Files changed

  • src/server/api/models/auth.models.tsConfirmEmailInputSchema.next
  • src/app/api/auth/confirm/route.tsconfirmSchema.next

Closes #241

@vercel
Copy link

vercel bot commented Feb 25, 2026

@taheerahmed is attempting to deploy a commit to the E2B Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e30060e057

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…ocalhost compatibility

z.httpUrl() rejects localhost URLs, causing Zod validation errors
during local development when verifying email. z.url() with a protocol
constraint still restricts to http/https while accepting localhost.
Existing isExternalOrigin checks already handle redirect security.

Closes e2b-dev#241
@taheerahmed taheerahmed force-pushed the fix/zod-localhost-validation branch from e30060e to 14a91a3 Compare February 25, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Zod validation error

1 participant