'How to change referer in Request header?

What i tried is

  1. Trigger Login API - Success
  2. Another post API to create customer - Failed due to cookie was not setting properly because i am trying it with localhost , so i tried to change the referer to the actual API host for example (https://www.somesite.com/someapi)

but i am unable to update the referer ,

**

 var headers = new Headers()
 headers.set('x-sk-session-id', sessionId)
 headers.set('sessionid', sessionId)
  
   fetch('some-url', {
    method:      'POST',
    credentials: 'include',
    // withCredentials: true,
    // mode:        'same-origin',
    origin: 'some-api.url.com',
    referer: 'some-api.url.com',
    headers: headers,
  }).then((res)=> res.json()).then((data)=> console.log(data)); 

**

But i am still getting Invalid Session id error from backend , due to cookie forwarding was failed



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source