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

Can not override Content-Type headers for ics #278

Open
eam-k opened this issue Dec 16, 2023 · 1 comment
Open

Can not override Content-Type headers for ics #278

eam-k opened this issue Dec 16, 2023 · 1 comment

Comments

@eam-k
Copy link

eam-k commented Dec 16, 2023

Context

  • I am sending a ics file
  • I set the headers like this:
 "headers": {
        "Content-Type": "text/calendar; charset=utf-8; method=REQUEST; name=invite.ics"
    },
  • The file is a string that I pass as:
   "attachments": [{
        "content": "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN...more details about invite",
        "filename": "invite.ics"
    }]
  • In Resend platform I am getting this error:
{
    "name": "application_error",
    "message": "Duplicate header 'Content-Type'.",
    "statusCode": 500
}

What should be expected?

Since I am the developer, I want to have freedom to set the headers. One of the reasons is to make sure the content is correctly interpreted when the attachment is sent. For example, when I see the attachment I can see that it is correctly sent as attachment but the content inside the file is not correct probably a buffer/unrecognizable characters, this confuses gmail and mark it as a potential risk, what I would expect from a library and the platform is:

  • Able to see the exact headers used
  • Override the headers

Notes

Hey devs, I just found out that using Buffer with uft-8 encoder did the trick:

{
  content: Buffer.from(iCalInvitation, 'utf-8'),
  filename: 'invite.ics',
},

I was trying to follow a mix between two examples, where the ics file was sent as a string (attachment).
https://github.com/resend/resend-examples/blob/main/with-ical/src/pages/api/send.ts

Turns out that sending a string is not enough, somehow the content is not interpreted correctly.

I also had some inconsistencies with my ics file so I decided to create a valid one from another platform, one that can be added to calendar and also to discard other factors in this issue , after getting a valid ics I tried to send it different ways, so Buffer was how I was able to send it without issues.

I will let this issue open so you guys can close it, if you close it I will assume you read this issue.

Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
@johanneskares
Copy link

same issue here

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

No branches or pull requests

2 participants