简体   繁体   中英

How to solve CORS error when using fake API?

I am using fake api and getting this well known "No 'Access-Control-Allow-Origin' header is present on the requested resource." I watched videos and read articles related to this problem but they are showing the solution while they are using their own server (express) and api but I am using a third party API then how I would set headers for it?

The errors:

错误(尽管它如此受欢迎以至于已经看到它 LOL))

A temporary shortcut solution: You can use an extension for your browser to solve CORS error. Allow CORS: Access-Control-Allow-Origin在此处输入图像描述

If you are using google chrome, you can simply disable web security during your development:

  1. Open cmd

  2. Go to chrome.exe installation dir ( C:\Program Files\Google\Chrome\Application is Default dir):

    cd C:\Program Files\Google\Chrome\Application

  3. Open chrome.exe with --disable-web-security argument:

    chrome.exe --disable-web-security

在此处输入图像描述

You can find more info for other OS here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM