electron线上跨域问题

一、配置background.js

bash 复制代码
 win = new BrowserWindow({
    webPreferences: {
      nodeIntegration: true, // 使渲染进程拥有node环境
      //关闭web权限检查,允许跨域
      webSecurity: false,
      // Use pluginOptions.nodeIntegration, leave this alone
      // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
      nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
      contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
    },
  });

参考官网:http://electronjs.p2hp.com/docs/latest/api/browser-window

二、配置axios基础路径

bash 复制代码
axios.defaults.baseURL = 'http://xx.xx.xx.xx';
相关推荐
爱分享的程序员几秒前
前端面试专栏-算法篇:17. 排序算法
前端·javascript·node.js
lichenyang4531 分钟前
react案例动态表单(受控组件)
前端
Jackson_Mseven1 分钟前
面试官:useEffect 为什么总背刺?我:闭包、ref 和依赖数组的三角恋
前端·react.js·面试
哎呦你好18 分钟前
【CSS】Grid 布局基础知识及实例展示
开发语言·前端·css·css3
盛夏绽放27 分钟前
接口验证机制在Token认证中的关键作用与优化实践
前端·node.js·有问必答
zhangxingchao44 分钟前
Jetpack Compose 之 Modifier(中)
前端
JarvanMo44 分钟前
理解 Flutter 中 GoRouter 的context.push与context.go
前端
pe7er1 小时前
使用 Vue 官方脚手架创建项目时遇到 Node 18 报错问题的排查与解决
前端·javascript·vue.js
星始流年1 小时前
前端视角下认识AI Agent
前端·agent·ai编程
pe7er1 小时前
使用 types / typings 实现全局 TypeScript 类型定义,无需 import/export
前端·javascript·vue.js