Update Row vue js beta CORS POLICY

Hi everyone,

I come back with a new problem including vue js with the beta:

GitHub - HubSpot/cms-vue-boilerplate: Boilerplate Vue project for creating apps using modules on the HubSpot CMS · GitHub.

I saw different problem talking about that, I don’t understand if severless function can help but I still fill strange if I need to use it to go through it.

So the point is :

1- show rows from hubdb using the get method(

https://api.hubapi.com/hubdb/api/v2/tables/)

: ok

2- show a specific row and edit it via get function method: ok

3- update row via put(v2 or v3, or patch(v3) : not work

i’m using axios to call the api, I get the famous message:

Access to XMLHttpRequest at ‘https://api.hubapi.com/hubdb/api/v3/tables/527xxx/rows/540843xxx?hapikey=eefcdea1-xxxx-48bd-bcxx-48xxxxx’ from origin ‘http://hubspot-developers-onhdqe-xxxxxxxx.hs-sites.com’ has been blocked by CORS policy: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.

I get the same message on v2, v3 put and patch

The code I used to make the call is the following one:

let updateContentUrl = URL.EDIT_INSIGHT + this.insightId + URL.API_KEY;

  const headers = {

      "Content-Type": "application/json",

      "Access-Control-Allow-Credentials": true,

      "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Accept-Charset, Accept-Encoding",

      "Access-Control-Allow-Methods": "PUT"

  };

  return axios.put(updateContentUrl, jsonFinal, { headers })

  .then( response => (console.log(response)))

  .catch(error => console.log(error))

I add one precision, I integrate the vue project as a module and I use it directly inside hubspot. My goal is to access/use the API directly within Hubspot so I can’t aford to use this project outside to fix the problem.

If someone can tell me if I missed something or I need to use an alternative way to update it is welcome.

Thanks for the help you can provide.

Kind regards.

Joan Varnavant

Hi @joan1 ,

I’ve had a similar problem in the past. In my case, the fact that I used a HubSpot URL was the problem (http://hubspot-developers-onhdqe-xxxxxxxx.hs-sites.com). HubSpot developer URLs do not have an SSL certificate (http instead of https) and that is a cause for the CORS error.

So if you have a domain connected or could connect a domain, you could resolve this issue.

Hi @Teun , thanks for the tips,
I will try to see by changing the domain so and see if the problem is fixed.
But That give another problem and question about that part, i’m not sure how it work but I absolutely need to play in a sandbox to do the test and upgrade before release it live, so is it possible to link a domain to the sandbox? Because actually if I go to the settings/Domain, that ask to upgrade to Hubspot CMS to publish the site. (Sandbox seems to don’t have the same right than main account).

Hi @joan1 ,

If you create a test account through a developer account (90 day active portal, can be renewed), you should be able to connect a domain. If you created a CMS Sandpox portal, you can not connect a domain.

So switching to a test account created through a developer account should help you resolve this.

You can read more about HubSpot account types here.

You can create a developer account here.

Hi @Teun ,

I see thanks for the tips, I will have a look on this solution to make it work.

Kind regards.

Joan