Serverless CORS Issue

Hi,

I’m getting a CORS error for trying to call my hubspot hosted serverless function from my hosted hubspot website page:

‘Access to fetch at https://mabletherapy.com/\_hcms/api/submitResponses’ from origin ’ https://www.mabletherapy.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

I’m using the same protocol and therefore should not be getting this error according to your docs:

{
“runtime”: “nodejs18.x”,
“version”: “1.0”,
“endpoints”: {
“submitResponses”: {
“method”: “POST”,
“file”: “submitResponses.js”
},
“submitContactForm”: {
“method”: “POST”,
“file”: “submitContactForm.js”
}
}
}

My headers for my api calls are as follows:

headers: {

“Content-Type”: “application/json”,

“Access-Control-Allow-Origin”: “*”

}

Is there a way to get around this error?

Hi @SamRahaMable,
Thank you for asking the Community!
I’d like to share these similar threads that might help you:
- Access to XMLHttpRequest blocked by CORS policy
- API Cors issue
- CORS issue
I hope it helps!
Have a lovely day!
Best,
Bérangère

@BérangèreL could we get some dev support please?

Hi @SamRahaMable,
Thank you for your message and sorry for the delay in the reply.
I’d like to invite a couple of subject matter experts to this conversation: Hi @zach_threadint, @MBERARD and @Teun do you have suggestions to help @SamRahaMable, please?
Also, if you are still having this issue, I would recommend connecting with HubSpot Technical Support, as Support is included in your subscription and they will be able to provide real-time assistance for this matter, including hopping on a screenshare if necessary.
Thank you and have a good day!
Best,
Bérangère

Hi Bérangère,

Thank you for sharing those articles. After reviewing them thoroughly, I found that none of them are relevant to my issue.

Could you please provide some development support on this?

P.s. I have added the domain www.mabletherapy.com over to the advanced tracking under settings.