<?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 Angular Accept.js CORS error in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Angular-Accept-js-CORS-error/m-p/71662#M44150</link>
    <description>&lt;P&gt;I am using Angular 7 and have to add the accept.js script dynamically with the following:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;const &lt;/SPAN&gt;node = &lt;SPAN&gt;document&lt;/SPAN&gt;.&lt;SPAN&gt;createElement&lt;/SPAN&gt;(&lt;SPAN&gt;'script'&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;src &lt;/SPAN&gt;= 'https://apitest.authorize.net/xml/v1/request.api'&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;type &lt;/SPAN&gt;= &lt;SPAN&gt;'text/javascript'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;charset &lt;/SPAN&gt;= &lt;SPAN&gt;'utf-8'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;document&lt;/SPAN&gt;.&lt;SPAN&gt;getElementsByTagName&lt;/SPAN&gt;(&lt;SPAN&gt;'head'&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;].&lt;SPAN&gt;appendChild&lt;/SPAN&gt;(node)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;When I run&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Accept.dispatchData(secureData, (acceptResponse: any) =&amp;gt; {&lt;BR /&gt;&lt;/SPAN&gt;  console.log(acceptResponse);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;I get the error&amp;nbsp;&amp;nbsp;Access to XMLHttpRequest at '&lt;A href="https://apitest.authorize.net/xml/v1/request.api" target="_blank"&gt;https://apitest.authorize.net/xml/v1/request.api&lt;/A&gt;' from origin 'https://localhost:8443' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.&lt;BR /&gt;POST &lt;A href="https://apitest.authorize.net/xml/v1/request.api" target="_blank"&gt;https://apitest.authorize.net/xml/v1/request.api&lt;/A&gt; net::ERR_FAILED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error only occurs when the Accept.js script is cached. If I clear the browser cache and dispatchData again, the CORS error doesn't occur.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does caching the script in Angular cause this error, and what can I do to stop it?&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2020 23:25:57 GMT</pubDate>
    <dc:creator>mchaffins7</dc:creator>
    <dc:date>2020-04-21T23:25:57Z</dc:date>
    <item>
      <title>Angular Accept.js CORS error</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Angular-Accept-js-CORS-error/m-p/71662#M44150</link>
      <description>&lt;P&gt;I am using Angular 7 and have to add the accept.js script dynamically with the following:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;const &lt;/SPAN&gt;node = &lt;SPAN&gt;document&lt;/SPAN&gt;.&lt;SPAN&gt;createElement&lt;/SPAN&gt;(&lt;SPAN&gt;'script'&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;src &lt;/SPAN&gt;= 'https://apitest.authorize.net/xml/v1/request.api'&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;type &lt;/SPAN&gt;= &lt;SPAN&gt;'text/javascript'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;node.&lt;SPAN&gt;charset &lt;/SPAN&gt;= &lt;SPAN&gt;'utf-8'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;document&lt;/SPAN&gt;.&lt;SPAN&gt;getElementsByTagName&lt;/SPAN&gt;(&lt;SPAN&gt;'head'&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;].&lt;SPAN&gt;appendChild&lt;/SPAN&gt;(node)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;When I run&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Accept.dispatchData(secureData, (acceptResponse: any) =&amp;gt; {&lt;BR /&gt;&lt;/SPAN&gt;  console.log(acceptResponse);&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;I get the error&amp;nbsp;&amp;nbsp;Access to XMLHttpRequest at '&lt;A href="https://apitest.authorize.net/xml/v1/request.api" target="_blank"&gt;https://apitest.authorize.net/xml/v1/request.api&lt;/A&gt;' from origin 'https://localhost:8443' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.&lt;BR /&gt;POST &lt;A href="https://apitest.authorize.net/xml/v1/request.api" target="_blank"&gt;https://apitest.authorize.net/xml/v1/request.api&lt;/A&gt; net::ERR_FAILED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error only occurs when the Accept.js script is cached. If I clear the browser cache and dispatchData again, the CORS error doesn't occur.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does caching the script in Angular cause this error, and what can I do to stop it?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:25:57 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Angular-Accept-js-CORS-error/m-p/71662#M44150</guid>
      <dc:creator>mchaffins7</dc:creator>
      <dc:date>2020-04-21T23:25:57Z</dc:date>
    </item>
  </channel>
</rss>

