简体   繁体   中英

How to Load JQuery in electron webview with proxy

I'm setting up an electron app, with a index.html that contains a webview. The webview got a reverse proxy attached to it, changing all "/" routes. This means that I can't load any CDN libraries (JQUERY) in the webview. Is there a way to still load JQUERY? currently if I try with:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>

I get error "Failed to load resource: net::ERR_EMPTY_RESPONSE".

I made the reverse proxy with express, changing route like this:

express.get('/', function (req, res) {
    res.sendFile('home.html', {root: __dirname});
})

Update:

Its not only jquery but also other libaries

It might be better to make the app not reliable on remote hosted libraries.

Your best shot might be to use a module bundler such as webpack , parcel or rollup to create a bundle of your application including the external libraries (such as jQuery, Axios or whatever code you rely on)

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