简体   繁体   中英

localhost - Cross origin requests are only supported for protocol schemes?

I have the following function:

this.Locations = axios.get('localhost:8081/fetchData?table=locations').then((res) => {                                         
  return res
})   

and in my app.js I have an endpoint set up '/fetchData' which works fine if I just execute in the browser.

How come I am getting this error message?

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

You need to specify a scheme, for example, http:// . Change your function to:

this.Locations = axios.get('http://localhost:8081/fetchData?table=locations').then((res) => {                                         
  return res
})   

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