<?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 How can I perform a web request with Authentication headers from a React based custom Visual? in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-can-I-perform-a-web-request-with-Authentication-headers-from/m-p/4888653#M12958</link>
    <description>&lt;P&gt;I'm making a React Based custom visual that is inteded to work with my connector, I have a table with URLs where each URL points to an image, you can request that image but the request needs to contain an authorization header, something like this in my React component:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; response = &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt;&lt;SPAN&gt; fetch(url, {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; method: &lt;/SPAN&gt;&lt;SPAN&gt;"GET"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; headers: {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"Authorization"&lt;/SPAN&gt;&lt;SPAN&gt;: AUTH_TOKEN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;BR /&gt;&lt;BR /&gt;At this moment, the token is hardcoded&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; AUTH_TOKEN = &lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;"Bearer eyJ...", my idea is to validate that I can load the images with this aproach, then I would figure it out how to generate or pass this token.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But I'm noticing that if I pass the headers, the request is not performed (If the headers are not passed, I can get the images from public sources, for example wikipedia images, but I need to be authenticated to get the images from the desired server)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ECorona_0-1764369993529.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1313582iE79231D71A7A580A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ECorona_0-1764369993529.png" alt="ECorona_0-1764369993529.png" /&gt;&lt;/span&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;But for my specific case (where the request needs to be authenticated, I'm getting an error):&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ECorona_0-1764370746326.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1313583i41DE0A909C41547B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ECorona_0-1764370746326.png" alt="ECorona_0-1764370746326.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;SPAN&gt;Looking in the Edge console I'm getting:&lt;BR /&gt;&lt;EM&gt;&lt;A href="https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg" target="_blank" rel="noopener"&gt;https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg&lt;/A&gt;' from origin 'null' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;component.tsx:59 &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;GET &lt;A href="https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg" target="_blank" rel="noopener"&gt;https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg&lt;/A&gt; net::ERR_FAILED&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;I'm getting the same message from the URL of my server.&lt;BR /&gt;&lt;BR /&gt;So, I'm assuming the request is being blocked by Power BI, is there a way to pass the headers in the request?&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 28 Nov 2025 22:59:16 GMT</pubDate>
    <dc:creator>ECorona</dc:creator>
    <dc:date>2025-11-28T22:59:16Z</dc:date>
    <item>
      <title>How can I perform a web request with Authentication headers from a React based custom Visual?</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-can-I-perform-a-web-request-with-Authentication-headers-from/m-p/4888653#M12958</link>
      <description>&lt;P&gt;I'm making a React Based custom visual that is inteded to work with my connector, I have a table with URLs where each URL points to an image, you can request that image but the request needs to contain an authorization header, something like this in my React component:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; response = &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt;&lt;SPAN&gt; fetch(url, {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; method: &lt;/SPAN&gt;&lt;SPAN&gt;"GET"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; headers: {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"Authorization"&lt;/SPAN&gt;&lt;SPAN&gt;: AUTH_TOKEN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;BR /&gt;&lt;BR /&gt;At this moment, the token is hardcoded&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; AUTH_TOKEN = &lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;"Bearer eyJ...", my idea is to validate that I can load the images with this aproach, then I would figure it out how to generate or pass this token.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But I'm noticing that if I pass the headers, the request is not performed (If the headers are not passed, I can get the images from public sources, for example wikipedia images, but I need to be authenticated to get the images from the desired server)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ECorona_0-1764369993529.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1313582iE79231D71A7A580A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ECorona_0-1764369993529.png" alt="ECorona_0-1764369993529.png" /&gt;&lt;/span&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;But for my specific case (where the request needs to be authenticated, I'm getting an error):&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ECorona_0-1764370746326.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1313583i41DE0A909C41547B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ECorona_0-1764370746326.png" alt="ECorona_0-1764370746326.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;SPAN&gt;Looking in the Edge console I'm getting:&lt;BR /&gt;&lt;EM&gt;&lt;A href="https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg" target="_blank" rel="noopener"&gt;https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg&lt;/A&gt;' from origin 'null' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;component.tsx:59 &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;GET &lt;A href="https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg" target="_blank" rel="noopener"&gt;https://upload.wikimedia.org/wikipedia/commons/1/17/Amblyglyphidodon_aureus001.jpg&lt;/A&gt; net::ERR_FAILED&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;I'm getting the same message from the URL of my server.&lt;BR /&gt;&lt;BR /&gt;So, I'm assuming the request is being blocked by Power BI, is there a way to pass the headers in the request?&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 28 Nov 2025 22:59:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-can-I-perform-a-web-request-with-Authentication-headers-from/m-p/4888653#M12958</guid>
      <dc:creator>ECorona</dc:creator>
      <dc:date>2025-11-28T22:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I perform a web request with Authentication headers from a React based custom Visual?</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-can-I-perform-a-web-request-with-Authentication-headers-from/m-p/4892557#M12971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/588741"&gt;@ECorona&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The CORS error you're seeing isn't from Power BI blocking the request - it's the server (wikimedia in your example) rejecting the Authorization header in the preflight request. The server needs to explicitly allow the Authorization header in its CORS configuration.&lt;/P&gt;&lt;P&gt;For your custom visual scenario, here are some options which I havent implemented by my self but might work:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Backend Proxy&lt;/STRONG&gt;: The most common solution is to route requests through a backend service you control. Your visual calls your backend, which then makes the authenticated request to the image server.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Power BI Service Account&lt;/STRONG&gt;: If your images are in a service that Power BI can connect to, consider using Power BI's built-in authentication mechanisms through your connector rather than client-side fetch.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Server CORS Configuration&lt;/STRONG&gt;: If you control the image server, ensure it returns these headers:&lt;/P&gt;&lt;PRE&gt;Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization&lt;/PRE&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Since you mentioned having a custom connector, the cleanest approach would be to fetch the images through Power BI's data pipeline (authenticated via the connector) and embed them as base64 data URIs in your dataset, rather than making client-side requests from the visual. Or if you want to use Fabric items you can also fetch the data with a pipeline which contains the HTTP request, store the images in OneLake at take them from there. But still the CORS policy is applied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;P&gt;PS: If you find this post helpful consider leaving kudos or mark it as solution&lt;/P&gt;</description>
      <pubDate>Thu, 04 Dec 2025 06:57:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/How-can-I-perform-a-web-request-with-Authentication-headers-from/m-p/4892557#M12971</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-12-04T06:57:41Z</dc:date>
    </item>
  </channel>
</rss>

