Closed xhc-code closed 7 months ago
If you use axios
in the Renderer process, you can config the Proxy in vite.renderer.config.mjs
import { defineConfig } from 'vite';
// https://vitejs.dev/config
export default defineConfig({
+ server: {
+ proxy: {},
+ },
});
If you use
axios
in the Renderer process, you can config the Proxy invite.renderer.config.mjs
import { defineConfig } from 'vite'; // https://vitejs.dev/config export default defineConfig({ + server: { + proxy: {}, + }, });
Thank you
This is not possible because Vite, after being built, is a static file and will not contain this configuration file. I expect it to be used in a production environment because using the file protocol has many limitations. The expectation is that after Electron starts, the proxy server starts, and Electron loads the content of this link through the loadURL
Pre-flight checklist
Problem description
I use electron-forge, which is an html page built by vite loaded through loadFile and loadurl. It is built using vite, but I encountered a problem, which is vite+vue+axios. The proxy service configuration configured through vite is not used by electron. , but how should I configure the front-end axios to request the interface URL of the specified address? I don't want to hard-code this path. I want to use environment variables to load different api interface URLs according to different environments. How can I achieve this?
Proposed solution
none
Alternatives considered
none
Additional information
No response