0

I use an api to send emails. I noticed that in order for it to work successfully I need to set a user-agent. So I put the following in my header for a POST request.

headers: {
  'user-agent': 'myapp/2022.6.0', 
  'content-type': 'application/json',
  'content-length': data.length,
  'accept': '*/*'
}

It works but I wonder if there is a pattern or can I just write anything in? What is the point then? Thanks in advance! Max

Notes I using nodeJs, and the Mail Api is web3Froms https://web3forms.com/#start.

Max Pattern
  • 1,430
  • 7
  • 18
  • 1
    An API requiring a `user-agent` to be provided is *very* odd. I'd suggest checking their documentation to see if they have any custom conventions you need to use, as this is not standard practice. In theory though, you can put whatever you like in that value. – Rory McCrossan Nov 03 '22 at 09:04
  • 1
    Are you sure the only requirement is `user-agent`? Most commonly, APIs require `content-type` or any headers related to the content itself. Otherwise, if they accept anything, it sounds like an effort to "make it more secure", which obviously failed :) – Andrey Popov Nov 03 '22 at 09:06
  • @RoryMcCrossan I use web3Forms. (https://web3forms.com/#start). Apparently it is only for client side use. But good that it still works that way. Until now !?! But thank you for your comment! – Max Pattern Nov 03 '22 at 09:39
  • @AndreyPopov Im not sure. It seems that (web3forms.com/#start) is only for the clientside usage :-/ . And many thanks for your good comment! – Max Pattern Nov 03 '22 at 09:40

0 Answers0