SimulatedGREG / electron-vue

An Electron & Vue.js quick start boilerplate with vue-cli scaffolding, common Vue plugins, electron-packager/electron-builder, unit/e2e testing, vue-devtools, and webpack.
https://simulatedgreg.gitbooks.io/electron-vue/content/
MIT License
15.46k stars 1.55k forks source link

CSP error when hot-reloading in sub-pages #858

Open mittalyashu opened 5 years ago

mittalyashu commented 5 years ago

Found an issue or bug with electron-vue? Tell me all about it!

On the homepage (a.k.a / route), when the app hot-reload there is no problem with the application it works perfectly fine, but when we move to sub-pages /repository/workspace and then try to make some changes to the code, the electron app shows a blank screen.

Describe the issue / bug.

It looks like the problem is in electron configuration, but it's not, instead, the problem is in the .electron-vue where the configuration of webpack exists.

I think when it reloads the page when the is in sub-routes, for some reason, it forgets the URL (or something similar)

How can I reproduce this problem?
If visual, provide a screenshot.

image

Tell me about your development environment.

Could be related to https://github.com/SimulatedGREG/electron-vue/issues/437

JBtje commented 5 years ago

My assumption is that the below code might be helpful. I placed it in:

src/main/index.js

function createWindow() {

   ...

    session.defaultSession.webRequest.onHeadersReceived( ( details, callback ) => {
        callback( {
            responseHeaders: {
                ...details.responseHeaders,
                'Content-Security-Policy': 'script-src \'self\' https://URL-TO-SITE.com',
            },
        } );
    } );
}