Feature/webinar landing (#552) - #553
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting
| if (!response.ok) { | ||
| // Check if subscriber already exists (200/201 are success, 400 might be duplicate) | ||
| if (response.status === 400 && data.message?.includes('already exists')) { | ||
| // Try to update existing subscriber | ||
| const updateResponse = await fetch(`https://api.mailerlite.com/api/v2/subscribers/${body.email}`, { | ||
| method: 'PUT', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-MailerLite-ApiKey': MAILERLITE_API_KEY |
There was a problem hiding this comment.
[P1] URL-encode email before calling MailerLite update endpoint
When handling a duplicate subscriber, the code constructs the update URL with https://api.mailerlite.com/api/v2/subscribers/${body.email}. If the email contains characters that are not legal in a path segment (e.g. +, spaces, non‑ASCII), the request will be interpreted incorrectly by the MailerLite API and the update attempt will fail. This means users who sign up with common aliasing patterns like user+promo@example.com will never get the graceful "already subscribed" path and will continue receiving an error. Wrap the email with encodeURIComponent before interpolating it into the URL.
Useful? React with 👍 / 👎.
No description provided.