<?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: NCS 5.3: preflight request Unauthorized (HTTP401) in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089341#M5263</link>
    <description>&lt;P&gt;Thanks for the explanation. It makes sense for disabled it because of the security concerns.&lt;BR /&gt;I have tried to set withCredentials flag before, but it seem to not working in firefox. Anyway I will go with reverse-proxy workaround, support case not needed for now.&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2020 14:07:23 GMT</pubDate>
    <dc:creator>nueasaks</dc:creator>
    <dc:date>2020-05-20T14:07:23Z</dc:date>
    <item>
      <title>NCS 5.3: preflight request Unauthorized (HTTP401)</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089183#M5260</link>
      <description>&lt;P&gt;Hi Guys,&lt;BR /&gt;&lt;BR /&gt;I found the problem while developing web front-end with javascript to make a request to NSO northbound API.&lt;BR /&gt;Due to CORS(&lt;STRONG&gt;Cross-Origin Resource Sharing)&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;mechanism browser will sent a preflight request to NSO before the main request.&lt;BR /&gt;&lt;BR /&gt;So, In NCS version 5.2 it working fine by adding CORS header in ncs.conf under &amp;lt;restconf&amp;gt;, But after changed the version from &lt;STRONG&gt;5.2 TO 5.3&lt;/STRONG&gt; (with same ncs.conf). It seem like NSO northbound API reply back 401&amp;nbsp;Unauthorized to the preflight request.&lt;BR /&gt;&lt;BR /&gt;I also tried to debug it with packet capture and here is the capture.&lt;BR /&gt;this tcpstream i got in &lt;STRONG&gt;version 5.3&lt;/STRONG&gt;:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;### this is the response in ncs 5.3  ####
&lt;EM&gt;&lt;STRONG&gt;&amp;lt;preflight request&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;
&lt;STRONG&gt;OPTIONS&lt;/STRONG&gt; /restconf/data/tailf-ncs:devices/device HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Accept: */*
Access-Control-Request-Method: GET
Access-Control-Request-Headers: authorization
Origin: http://localhost:3000
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
Sec-Fetch-Dest: empty
Referer: http://localhost:3000/service/new

&lt;STRONG&gt;&lt;EM&gt;&amp;lt;401 error response&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;
&lt;STRONG&gt;HTTP/1.1 401 Unauthorized&lt;/STRONG&gt;
Date: Sun, 03 May 2020 13:43:34 GMT
Content-Length: 169
Content-Type: application/yang-data+xml
WWW-Authenticate: Basic realm="restconf"
Content-Security-Policy: default-src 'self'; block-all-mixed-content; base-uri 'self'; frame-ancestors 'none';
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

&amp;lt;errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf"&amp;gt;
  &amp;lt;error&amp;gt;
    &amp;lt;error-tag&amp;gt;access-denied&amp;lt;/error-tag&amp;gt;
    &amp;lt;error-type&amp;gt;protocol&amp;lt;/error-type&amp;gt;
  &amp;lt;/error&amp;gt;
&amp;lt;/errors&amp;gt;&lt;/PRE&gt;
&lt;P&gt;As i'm understanding broswer will not send any&amp;nbsp;&lt;STRONG&gt;Authorization/Credential&amp;nbsp;&lt;/STRONG&gt;in the preflight request header by default.&lt;BR /&gt;NOTE : I tried to request it manually by postman, it working fine and got CORS header back in the response.&lt;BR /&gt;&lt;BR /&gt;compare to the mechanism in &lt;STRONG&gt;ncs 5.2&lt;/STRONG&gt; :&lt;/P&gt;
&lt;PRE&gt;### this is the response in ncs 5.2   ####
&lt;EM&gt;&lt;STRONG&gt;&amp;lt;preflight request&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;
&lt;STRONG&gt;OPTIONS&lt;/STRONG&gt; /restconf/data/tailf-ncs:devices/device HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Accept: */*
Access-Control-Request-Method: GET
Access-Control-Request-Headers: authorization
Origin: http://localhost:3000
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
....&amp;lt;snippet output&amp;gt;
&lt;EM&gt;&lt;STRONG&gt;&amp;lt;respose with cors header permission&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;
&lt;STRONG&gt;HTTP/1.1 200 OK&lt;/STRONG&gt;
Date: Sun, 03 May 2020 13:29:46 GMT
Allow: DELETE, GET, HEAD, PATCH, POST, PUT, OPTIONS
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Content-Length: 0
Content-Type: text/html
Accept-Patch: application/yang-data+xml, application/yang-data+json
&lt;EM&gt;Access-Control-Allow-Headers: Accept, Content-Type, Authorization, Accept-Encoding, Host, Origin, Content-Encoding, X-PING, X-PINGOTHER
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Origin: *&lt;/EM&gt;
....&amp;lt;snippet output&amp;gt;
&lt;EM&gt;&lt;STRONG&gt;&amp;lt;actual request with Authorization&amp;gt;&lt;/STRONG&gt;&lt;/EM&gt;
&lt;STRONG&gt;GET&lt;/STRONG&gt; /restconf/data/tailf-ncs:devices/device HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Accept: application/yang-data+json
&lt;STRONG&gt;Authorization: Basic YWRtaW46YWRtaW4=&lt;/STRONG&gt;
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
Origin: http://localhost:3000
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:3000/service/new
....&amp;lt;snippet output&amp;gt;
&lt;STRONG&gt;&lt;EM&gt;&amp;lt;response&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;
&lt;STRONG&gt;HTTP/1.1 200 OK&lt;/STRONG&gt;
Date: Sun, 03 May 2020 13:29:46 GMT
Last-Modified: Fri, 13 Mar 2020 04:00:54 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Etag: "1584-43963-840187"
Content-Type: application/yang-data+json
Transfer-Encoding: chunked
&lt;EM&gt;Access-Control-Allow-Headers: Accept, Content-Type, Authorization, Accept-Encoding, Host, Origin, Content-Encoding, X-PING, X-PINGOTHER
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Origin: *&lt;/EM&gt;
Pragma: no-cache

100F
{
  "tailf-ncs:device": [
    {
      "name": "acc1",
      "address": "127.0.0.1",
      "port": 10026,
      "ssh": {
        "host-key": [
          {
....&amp;lt;snippet output&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;I also implement an workaround by creating nginx-reverse-proxy to handle the preflight request.&lt;BR /&gt;But my question is what the best solution without&amp;nbsp;reverse-proxy in the middle or do i miss any additional configuration to make it working ?&lt;BR /&gt;&lt;BR /&gt;Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Here is config i'm using :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;  &amp;lt;restconf&amp;gt;
    &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;
    &amp;lt;custom-headers&amp;gt;
     &amp;lt;header&amp;gt;
          &amp;lt;name&amp;gt;Access-Control-Allow-Origin&amp;lt;/name&amp;gt;
          &amp;lt;value&amp;gt;*&amp;lt;/value&amp;gt;
     &amp;lt;/header&amp;gt;
     &amp;lt;header&amp;gt;
          &amp;lt;name&amp;gt;Access-Control-Allow-Methods&amp;lt;/name&amp;gt;
          &amp;lt;value&amp;gt;GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS&amp;lt;/value&amp;gt;
     &amp;lt;/header&amp;gt;
     &amp;lt;header&amp;gt;
         &amp;lt;name&amp;gt;Access-Control-Allow-Credentials&amp;lt;/name&amp;gt;
         &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;
     &amp;lt;/header&amp;gt;
     &amp;lt;header&amp;gt;
          &amp;lt;name&amp;gt;Access-Control-Allow-Headers&amp;lt;/name&amp;gt;
          &amp;lt;value&amp;gt;Accept, Content-Type, Authorization, Accept-Encoding, Host, Origin, Content-Encoding, X-PING, X-PINGOTHER&amp;lt;/value&amp;gt;
     &amp;lt;/header&amp;gt;
    &amp;lt;/custom-headers&amp;gt;
  &amp;lt;/restconf&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 09:46:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089183#M5260</guid>
      <dc:creator>nueasaks</dc:creator>
      <dc:date>2020-05-20T09:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: NCS 5.3: preflight request Unauthorized (HTTP401)</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089279#M5261</link>
      <description>This was disabled (NSO versions 5.3, 5.2.2, 5.1.3, 4.7.6, 4.6.5) due to the possibility to anuathenticated poke paths for existance.&lt;BR /&gt;The W3C CORS standard however states that credentials should not be sent with CORS preflight check.&lt;BR /&gt;It is not possible to disable the credentials requirement for CORS preflight, please open a support ticket for this.</description>
      <pubDate>Wed, 20 May 2020 12:34:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089279#M5261</guid>
      <dc:creator>perander</dc:creator>
      <dc:date>2020-05-20T12:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: NCS 5.3: preflight request Unauthorized (HTTP401)</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089284#M5262</link>
      <description>Note that it is possible to set withCredentials with XMLHttpRequest.&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials&lt;/A&gt;&lt;BR /&gt;Unsure about browser support for similar behaviour.</description>
      <pubDate>Wed, 20 May 2020 12:40:33 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089284#M5262</guid>
      <dc:creator>perander</dc:creator>
      <dc:date>2020-05-20T12:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: NCS 5.3: preflight request Unauthorized (HTTP401)</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089341#M5263</link>
      <description>&lt;P&gt;Thanks for the explanation. It makes sense for disabled it because of the security concerns.&lt;BR /&gt;I have tried to set withCredentials flag before, but it seem to not working in firefox. Anyway I will go with reverse-proxy workaround, support case not needed for now.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 14:07:23 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/ncs-5-3-preflight-request-unauthorized-http401/m-p/4089341#M5263</guid>
      <dc:creator>nueasaks</dc:creator>
      <dc:date>2020-05-20T14:07:23Z</dc:date>
    </item>
  </channel>
</rss>

