# I can't test api endpoints on localhost

**URL:** <https://community.hubspot.com/t/i-cant-test-api-endpoints-on-localhost/115751>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [September 4, 2024, 9:50am UTC](https://community.hubspot.com/t/i-cant-test-api-endpoints-on-localhost/115751 "2024-09-04T09:50:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MAlmeida4](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@MAlmeida4](https://community.hubspot.com/u/MAlmeida4)\
**Post date:** [September 4, 2024, 9:50am UTC](https://community.hubspot.com/t/i-cant-test-api-endpoints-on-localhost/115751/1 "2024-09-04T09:50:29Z")

</div>

I implemented contact creation and I can’t test it on localhost. It’s giving me a CORS error.  
I’ve tried several approaches and nothing works. Here’s what I’ve tried so far:

```lia-code-sample
 axios.defaults.headers.common['Authorization'] = `Bearer ${publicRuntimeConfig.ACCESS_TOKEN}`;
 axios.defaults.headers.common['Content-Type'] = `application/json`;
 axios.defaults.headers.common['Access-Control-Allow-Origin'] = `*`;
 axios.defaults.headers.common['Access-Control-Allow-Headers'] = `*`;
 axios.defaults.headers.common['Access-Control-Allow-Credentials'] = 'true';
 axios.defaults.headers.common['Access-Control-Allow-Methods'] = 'GET,HEAD,OPTIONS,POST,PUT';

 axios.post(`https://api.hubapi.com/crm/v3/objects/contacts`, props)
 .then((e) => {
 console.log('Response');
 })
 .catch(() => {
 console.log('ERROR');
 setErrorState();
 });

```

```lia-code-sample
 const endpoint = "https://api.hubapi.com/crm/v3/objects/contacts";

 const data = await fetch(endpoint, {
 headers: {
 "Content-Type": "application/json",
 "Authorization": `Bearer ${publicRuntimeConfig.ACCESS_TOKEN}`
 },
 method: 'POST',
 body: JSON.stringify(props)
 })
 .then(response => {
 console.log('response');
 })
 .catch(error => {
 console.log('ERROR');
 setErrorState();
 });

```

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 5, 2024, 7:26pm UTC](https://community.hubspot.com/t/i-cant-test-api-endpoints-on-localhost/115751/2 "2024-09-05T19:26:54Z")

</div>

Hey, @MAlmeida4 👋 Regarding the CORS issue, that is the expected behaviour. You’ll need to look into other solutions:

- create a backend proxy
- utilize a service like [**ngrok**](https://ngrok.com/)
- use Postman or CURL to make requests directly to the endpoint(s) you are working with

Have fun testing! — Jaycee
