<?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 to set Access-Control-Allow-Header for KV Store in Splunk 7.3.4 in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-set-Access-Control-Allow-Header-for-KV-Store-in-Splunk-7/m-p/501988#M85543</link>
    <description>&lt;P&gt;I created a web app that runs in Splunk. It is installed in $SPLUNK_HOME/etc/apps . The user can enter some data in a form, and then the data is saved in the KV Store. The data is sent to the kv store by using the javascript method fetch(). This is what a POST request looks like:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
fetch(&lt;BR /&gt;
  "my_kv_store_url",&lt;BR /&gt;
     {&lt;BR /&gt;
     method: "POST",&lt;BR /&gt;
     mode: "cors",&lt;BR /&gt;
     credentials: "include",&lt;BR /&gt;
     headers: {&lt;BR /&gt;
               "Content-Type": "application/json",&lt;BR /&gt;
        },&lt;BR /&gt;
     body: JSON.stringify(formData),&lt;BR /&gt;
        }&lt;BR /&gt;
     )&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The data is successfully added to the kv store in Splunk 8+. It has a &lt;CODE&gt;server.conf&lt;/CODE&gt; file which includes these lines:&lt;BR /&gt;
&lt;CODE&gt;[httpServer]  &lt;BR /&gt;
crossOriginSharingHeaders = X-Splunk-Form-Key, Authorization, Accept ,Content-Type, User-Agent,Referer&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However, when I run the app in Splunk version 7.x the POST requests are blocked with this error: "Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response". &lt;/P&gt;

&lt;P&gt;Splunk v7 does not support the crossOriginSharingHeaders rule in server.conf. &lt;/P&gt;

&lt;P&gt;How can I make this work in Splunk 7x?&lt;/P&gt;</description>
    <pubDate>Thu, 21 May 2020 19:31:52 GMT</pubDate>
    <dc:creator>wstrellis</dc:creator>
    <dc:date>2020-05-21T19:31:52Z</dc:date>
    <item>
      <title>How to set Access-Control-Allow-Header for KV Store in Splunk 7.3.4</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-set-Access-Control-Allow-Header-for-KV-Store-in-Splunk-7/m-p/501988#M85543</link>
      <description>&lt;P&gt;I created a web app that runs in Splunk. It is installed in $SPLUNK_HOME/etc/apps . The user can enter some data in a form, and then the data is saved in the KV Store. The data is sent to the kv store by using the javascript method fetch(). This is what a POST request looks like:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
fetch(&lt;BR /&gt;
  "my_kv_store_url",&lt;BR /&gt;
     {&lt;BR /&gt;
     method: "POST",&lt;BR /&gt;
     mode: "cors",&lt;BR /&gt;
     credentials: "include",&lt;BR /&gt;
     headers: {&lt;BR /&gt;
               "Content-Type": "application/json",&lt;BR /&gt;
        },&lt;BR /&gt;
     body: JSON.stringify(formData),&lt;BR /&gt;
        }&lt;BR /&gt;
     )&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The data is successfully added to the kv store in Splunk 8+. It has a &lt;CODE&gt;server.conf&lt;/CODE&gt; file which includes these lines:&lt;BR /&gt;
&lt;CODE&gt;[httpServer]  &lt;BR /&gt;
crossOriginSharingHeaders = X-Splunk-Form-Key, Authorization, Accept ,Content-Type, User-Agent,Referer&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However, when I run the app in Splunk version 7.x the POST requests are blocked with this error: "Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response". &lt;/P&gt;

&lt;P&gt;Splunk v7 does not support the crossOriginSharingHeaders rule in server.conf. &lt;/P&gt;

&lt;P&gt;How can I make this work in Splunk 7x?&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 19:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-set-Access-Control-Allow-Header-for-KV-Store-in-Splunk-7/m-p/501988#M85543</guid>
      <dc:creator>wstrellis</dc:creator>
      <dc:date>2020-05-21T19:31:52Z</dc:date>
    </item>
  </channel>
</rss>

