Dealing with 'Access-Control-Allow-Origin' header


#1

While testing on my local environment I use a CORS plugin to be able to do this kind of request .
However when deployed im getting the CORS error. How can I bypass this limitation so that newsletter works on my live site. The error im getting is the following.

XMLHttpRequest cannot load https://forms.hubspot.com/uploads/form/v2/4506xx/xxe6eaa5-xxxx-4f81-a498-1198687031f7. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://jerxxx-fe-dev.xxxx.com’ is therefore not allowed access.

Note: live site address is censored. I can provide it if needed


#2

@luisfoundation our APIs don’t support CORS requests, so if you’re using JavaScript for this, you’d need to send the data from the page to your server, and then have your server make the request to HubSpot.


#3

Is this on your roadmap to add? Would be very convenient as we’re using a static site builder so have no backend to submit to. Currently our forms submit to FormBucket but would like to submit these directly to HubSpot.


#4

We have some long term plans to allow AJAX requests specifically for form submissions, but we don’t have any plans to allow that for our APIs in general.


#6

Any news on this? I am also running into the same issue. Unfortunately, our website was built by a third-party and I don’t have the ability to send the request from the server.

All I’m trying to do is to submit a form through a JQuery post request.


#7

I’d love to have this too. I need this for the form submission endpoint.


#8

@ozzyonfire @MartinMuzatko There aren’t any plans to release this is the short run so I do not have any update for you.

@ozzyonfire Could you host your own server to proxy the data through to HubSpot? You could make an AJAX request to your own server and then make the proper server-side request to HubSpot to submit the form data.


#9

Ya that’s exactly what I ended up doing.


#10

Does this still need to be handled by proxying from another server to Hubspot?


#11

@foundryideas Yes, there hasn't been any changes on this front.


#12

I ran into this same issue the other day and wrote up some instructions on how I got around this issue.

The gist of the post is: use your own server to make the server side request and then dump the json onto your page and enable CORS. Then you can make all the AJAX calls that you need. It only takes two lines of PHP so it's very simple to do.