<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I can't test api endpoints on localhost in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/I-can-t-test-api-endpoints-on-localhost/m-p/1037172#M76423</link>
    <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/820805"&gt;@MAlmeida4&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Regarding the CORS issue, that is the expected behaviour. You'll need to look into other solutions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;create a backend proxy&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;utilize a service like &lt;A href="https://ngrok.com/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;ngrok&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;use Postman or CURL to make requests directly to the endpoint(s) you are working with&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Have fun testing! — Jaycee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2024 19:26:54 GMT</pubDate>
    <dc:creator>Jaycee_Lewis</dc:creator>
    <dc:date>2024-09-05T19:26:54Z</dc:date>
    <item>
      <title>I can't test api endpoints on localhost</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/I-can-t-test-api-endpoints-on-localhost/m-p/1036280#M76370</link>
      <description>&lt;P&gt;I implemented contact creation and I can't test it on localhost. It's giving me a CORS error.&lt;BR /&gt;I've tried several approaches and nothing works. Here's what I've tried so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; 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) =&amp;gt; {
                            console.log('Response');
                        })
                        .catch(() =&amp;gt; {
                            console.log('ERROR');
                            setErrorState();
                        });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; 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 =&amp;gt; {
                console.log('response');
            })
            .catch(error =&amp;gt; {
                console.log('ERROR');
                setErrorState();
            });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 09:50:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/I-can-t-test-api-endpoints-on-localhost/m-p/1036280#M76370</guid>
      <dc:creator>MAlmeida4</dc:creator>
      <dc:date>2024-09-04T09:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: I can't test api endpoints on localhost</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/I-can-t-test-api-endpoints-on-localhost/m-p/1037172#M76423</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/820805"&gt;@MAlmeida4&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Regarding the CORS issue, that is the expected behaviour. You'll need to look into other solutions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;create a backend proxy&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;utilize a service like &lt;A href="https://ngrok.com/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;ngrok&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;use Postman or CURL to make requests directly to the endpoint(s) you are working with&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Have fun testing! — Jaycee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 19:26:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/I-can-t-test-api-endpoints-on-localhost/m-p/1037172#M76423</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-09-05T19:26:54Z</dc:date>
    </item>
  </channel>
</rss>

