gpt4 book ai didi

javascript - ionic 电容器网络错误 "at t.exports (http://localhost/js/chunk-vendors.6faaceee.js:7:66512)\n "使用 Android 模拟器

转载 作者:行者123 更新时间:2023-12-05 00:05:52 27 4
gpt4 key购买 nike

我正在使用 Ionic/Vue 和简单的 axios 向我的服务器发送请求。它运行良好,直到我使用电容器 ionic capacitor copy android 在 android 模拟器上运行它。但是当我尝试登录到 android 模拟器时,它给了我这个错误。请帮忙

2019-07-14 18:48:06.318 9746-9896/io.ionic.starter I/Capacitor/Plugin/Console: {"message":"Network Error","name":"Error","stack":"Error: Network Error\n at t.exports (http://localhost/js/chunk-vendors.6faaceee.js:7:66512)\n at XMLHttpRequest.l.onerror (http://localhost/js/chunk-vendors.6faaceee.js:43:11967)","config":{"url":"http://192.168.1.7:3333/api/auth/login","method":"post","data":"{\"username\":\"\",\"password\":\"\"}","headers":{"0":"application/json","Content-Type":"application/json;charset=utf-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept"},"proxy":{"host":"http://192.168.1.7","port":"3333"},"baseURL":"http://192.168.1.7:3333/","transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1}}

最佳答案

这是一个 CORS 错误。所以你需要在你的 Vue 应用中使用代理。

// vue.config.js
module.exports = {
devServer: {
proxy: 'http://YOUR_API_URL'
}
}
// AND call 'http://localhost' for api call

关于javascript - ionic 电容器网络错误 "at t.exports (http://localhost/js/chunk-vendors.6faaceee.js:7:66512)\n "使用 Android 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57026714/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com