You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a post processing step for our rendered emails that parses the HTML and swaps out links for tracking links, like so:
import{renderAsync}from"./email-render/render-async";import*ascheeriofrom"cheerio";importtypeReactfrom"react";exportconstBASE_EMAIL_CLICK_TRACKING_URL="https://www.ourdomain.com/api/emails/click";exportconstBASE_EMAIL_OPEN_TRACKING_URL="https://www.ourdomain.com/api/emails/open";constrenderEmailTemplate=async(email: React.ReactElement,emailId: string|null)=>{constrenderedEmail=awaitrenderAsync(email,{pretty: true,});if(!emailId){returnrenderedEmail;}// Extract links from the rendered emailconstparsedHtml=cheerio.load(renderedEmail);parsedHtml("a").each((_,element)=>{constlink=parsedHtml(element).attr("href");if(link&&!link.startsWith("mailto:")&&!link.includes(BASE_EMAIL_OPEN_TRACKING_URL)){consttransformedUrl=newURL(BASE_EMAIL_CLICK_TRACKING_URL);transformedUrl.searchParams.append("emailId",emailId);transformedUrl.searchParams.append("next",link);consttransformedLink=transformedUrl.toString();parsedHtml(element).attr("href",transformedLink);}});// Todo actually figure out the double encoding issuereturnparsedHtml.html().replace(/&next=/gi,"&next=");};exportdefaultrenderEmailTemplate;// and we use it like so, where EmailTemplate is the react componentconsthtml=awaitrenderEmailTemplate(EmailTemplate,emailId);
In the latest version, we get this exception
Which package is affected (leave empty if unsure)
react-email
Link to the code that reproduces this issue
Seen above
To Reproduce
Import 'cheerio' anywhere in the code base of the dev server
Expected Behavior
Importing cheerio works
What's your node version? (if relevant)
No response
The text was updated successfully, but these errors were encountered:
Describe the Bug
We have a post processing step for our rendered emails that parses the HTML and swaps out links for tracking links, like so:
In the latest version, we get this exception
Which package is affected (leave empty if unsure)
react-email
Link to the code that reproduces this issue
Seen above
To Reproduce
Import 'cheerio' anywhere in the code base of the dev server
Expected Behavior
Importing cheerio works
What's your node version? (if relevant)
No response
The text was updated successfully, but these errors were encountered: