Score:0

CORS ERROR : "URL scheme "origin" is not supported." to fetch api

de flag

A 'CORS' error occurred while transmitting data from the client to the service. Therefore, "Access-Control-Allow-Origin" was added to the 'HTTP response header' to the IIS and to the WCF-Web.config.

However, the following error occurred.

test client_1.html:11 Fetch API cannot load origin: http://localhost:59755/StudentService.svc/

Ply_GetGamedata. URL scheme "origin" is not supported.

-MY client Code

  function PostFetch() {
  fetch('Origin: http://localhost:59755/StudentService.svc/Ply_GetGamedata', {
          method: "POST",             
          headers: {                     
              "Content-Type": "application/json",
          },
          mode: 'cors',                   
          cache: 'no-cache',          
          credentials: 'same-origin', 
          body: JSON.stringify({
              id: 11111111,
              password: "A0"**strong text**
          }),
      })
      .then((response) => response.json())
      .then((data) => console.log(data));

}

-Web.config in My service Code

 <httpProtocol>
  <customHeaders>
      <add name="Access-Control-Allow-Origin" value="*" />
      <add name="Access-Control-Allow-Headers" value="Content-Type" />
      <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" />
      <add name="Access-Control-Allow-Credentials" value="true" />
  </customHeaders>

If don't attach 'origin', this error will occur. Where should I put "origin"?

(http://localhost:59755/StudentService.svc/Ply_GetGamedata)

Access to XMLHttpRequest at 'localhost:59755/Service1.svc/Test' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

how can it be done? Thanks all

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.