<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CORS error when posting to &#x2F;oauth2&#x2F;token]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I get the following error when trying to sign in:</p>
<p dir="auto"><code>Access to XMLHttpRequest at ... has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.</code></p>
<p dir="auto"><img src="/community/forum/assets/uploads/files/1614102623843-capture-d-%C3%A9cran-2021-02-23-%C3%A0-18.37.05.png" alt="Capture d’écran 2021-02-23 à 18.37.05.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Here is a screenshot of the Network tab:</p>
<p dir="auto"><img src="/community/forum/assets/uploads/files/1614102886630-capture-d-%C3%A9cran-2021-02-23-%C3%A0-18.37.19.png" alt="Capture d’écran 2021-02-23 à 18.37.19.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The problem is the same with different application URLs:</p>
<ul>
<li><a href="http://localhost:8100" rel="nofollow ugc">http://localhost:8100</a></li>
<li><a href="https://localhost:8100" rel="nofollow ugc">https://localhost:8100</a></li>
<li><a href="http://etc-host.me:8100" rel="nofollow ugc">http://etc-host.me:8100</a> (with an entry in /etc/hosts)</li>
<li><a href="https://etc-host.me:8100" rel="nofollow ugc">https://etc-host.me:8100</a> (with an entry in /etc/hosts)</li>
</ul>
<p dir="auto"><img src="https://fusionauth.io/community/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/2139.png?v=rcgg4tg866g" class="not-responsive emoji emoji-android emoji--information_source" style="height:23px;width:auto;vertical-align:middle" title=":information_source:" alt="ℹ" /> When I use <strong>Postman</strong>, there is no CORS issue and this POST request to <code>/oauth2/token</code> works and I get valid Access and ID tokens.</p>
<h2>FusionAuth configuration</h2>
<ul>
<li>IDP: SAML2 (linked to an Auth0 application)</li>
<li>Cors settings:</li>
</ul>
<p dir="auto"><img src="/community/forum/assets/uploads/files/1614102766840-capture-d-%C3%A9cran-2021-02-23-%C3%A0-18.34.21.png" alt="Capture d’écran 2021-02-23 à 18.34.21.png" class=" img-fluid img-markdown" /></p>
<h2>My configuration</h2>
<ul>
<li>OS: MacOSX 10.15.7</li>
<li>Browser: Google Chrome Version 88.0.4324.182 (Build officiel) (x86_64)</li>
</ul>
<p dir="auto">Thanks a lot <img src="https://fusionauth.io/community/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f603.png?v=rcgg4tg866g" class="not-responsive emoji emoji-android emoji--smiley" style="height:23px;width:auto;vertical-align:middle" title=":smiley:" alt="😃" /> !</p>
]]></description><link>https://fusionauth.io/community/forum/topic/835/cors-error-when-posting-to-oauth2-token</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 06:18:29 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/835.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Feb 2021 18:04:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Tue, 05 Oct 2021 05:37:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/376">@pleymor</a> said in <a href="/community/forum/post/2467">CORS error when posting to /oauth2/token</a>:</p>
<blockquote>
<p dir="auto">Access to XMLHttpRequest at ... has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.</p>
</blockquote>
<p dir="auto">The Same Origin Policy (SOP) is a security measure standardized among browsers. It is needed to prevent Cross-Site Request Forgery (CSRF). The "Origin" mostly refers to a "Domain". Same Origin Policy prevents different origins (domains) from interacting with each other, to prevent attacks such as CSRF (Cross Site Request Forgery) through such requests, like AJAX. In other words, the browser would not allow any site to make a request to any other site. Without Same Origin Policy , any web page would be able to access the DOM of other pages.</p>
<p dir="auto">This SOP (Same Origin Policy) exists because it is too easy to inject a link to a javascript file that is on a different domain. This is actually a security risk ; you really only want code that comes from the site you are on to execute and not just any code that is out there.</p>
<p dir="auto">If you want to bypass that restriction when fetching the contents with fetch API or XMLHttpRequest in <a href="http://net-informations.com/js/iq/default.htm" rel="nofollow ugc">javascript</a>, you can use a proxy server so that it sets the header Access-Control-Allow-Origin to *.</p>
<p dir="auto">If you need to enable CORS on the server in case of localhost, you need to have the following on request header.</p>
<pre><code>Access-Control-Allow-Origin: http://localhost:9999
</code></pre>
]]></description><link>https://fusionauth.io/community/forum/post/3780</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/3780</guid><dc:creator><![CDATA[germyrinn]]></dc:creator><pubDate>Tue, 05 Oct 2021 05:37:03 GMT</pubDate></item><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Fri, 21 May 2021 14:20:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/653">@IzioDev</a> thanks a lot !!!!<br />
I have been looking for 2 weeks for the right way to implement it</p>
]]></description><link>https://fusionauth.io/community/forum/post/3078</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/3078</guid><dc:creator><![CDATA[yehoudaB]]></dc:creator><pubDate>Fri, 21 May 2021 14:20:46 GMT</pubDate></item><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Thu, 11 Mar 2021 13:41:35 GMT]]></title><description><![CDATA[<p dir="auto">In my case I fixed it by adding CORS headers to my <code>reverse-proxy</code> (traefik v2). Here's how :</p>
<pre><code class="language-yaml">version: "3.7"

services:
  # Traefik
  reverse-proxy:
    labels:
      traefik.http.middlewares.corsheaders.headers.accesscontrolalloworigin: "*"
      traefik.http.middlewares.corsheaders.headers.accesscontrolallowheaders: "*"

  # Nest
  api:
    labels:
      - traefik.http.routers.api.middlewares=corsheaders
</code></pre>
<p dir="auto">This allow all origin and all headers (this isn't secured but this works for development use).</p>
]]></description><link>https://fusionauth.io/community/forum/post/2586</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2586</guid><dc:creator><![CDATA[IzioDev]]></dc:creator><pubDate>Thu, 11 Mar 2021 13:41:35 GMT</pubDate></item><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Thu, 25 Feb 2021 16:26:19 GMT]]></title><description><![CDATA[<p dir="auto">Glad you solved it!</p>
]]></description><link>https://fusionauth.io/community/forum/post/2494</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2494</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Thu, 25 Feb 2021 16:26:19 GMT</pubDate></item><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Wed, 24 Feb 2021 08:49:31 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/20">@dan</a>,</p>
<p dir="auto">Thanks a lot for your fast reaction!</p>
<p dir="auto">I'm using FusionAuth 1.24.0, and yes there is a reverse proxy to reach it.</p>
<p dir="auto">It was the same with several browsers.</p>
<p dir="auto">Thank you, the solution was what you suggested <img src="https://fusionauth.io/community/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f4a1.png?v=rcgg4tg866g" class="not-responsive emoji emoji-android emoji--bulb" style="height:23px;width:auto;vertical-align:middle" title=":bulb:" alt="💡" /></p>
<p dir="auto">We manually added the header <code>"Access-Control-Allow-Origin": window.location.origin</code> in our call to  <code>/oauth2/token</code>, and it worked <img src="https://fusionauth.io/community/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/2728.png?v=rcgg4tg866g" class="not-responsive emoji emoji-android emoji--sparkles" style="height:23px;width:auto;vertical-align:middle" title=":sparkles:" alt="✨" /></p>
]]></description><link>https://fusionauth.io/community/forum/post/2474</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2474</guid><dc:creator><![CDATA[pleymor]]></dc:creator><pubDate>Wed, 24 Feb 2021 08:49:31 GMT</pubDate></item><item><title><![CDATA[Reply to CORS error when posting to &#x2F;oauth2&#x2F;token on Tue, 23 Feb 2021 22:40:34 GMT]]></title><description><![CDATA[<p dir="auto">Hiya @adrien-laugueux ,</p>
<p dir="auto">Really appreciate all the detail in this forum post. A few more questions:</p>
<ul>
<li>What version of FusionAuth are you using?</li>
<li>Are you proxying access to <a href="http://auth.southpigalle.io" rel="nofollow ugc">auth.southpigalle.io</a> or is does that request go directly to FusionAuth?</li>
<li>Does this issue happen with browsers other than Chrome?</li>
<li>What do the token endpoint headers look like? Are there any <code>access-control*</code> headers sent?</li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/2472</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/2472</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Tue, 23 Feb 2021 22:40:34 GMT</pubDate></item></channel></rss>