capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
318 stars 58 forks source link

[CSP issues] refuses to load inline styles, I have no ideia what to add anymore. #271

Open FranciscoKloganB opened 8 months ago

FranciscoKloganB commented 8 months ago

Describe the bug

I have two issues with a newly created application.

The main issue

The Content Security Policy Issue

With respect to the CSP errors on the console I changed the setup.ts file to the below but the error remains

// Set a CSP up for our application based on the custom scheme
export function setupContentSecurityPolicy(customScheme: string): void {
  session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
    callback({
      responseHeaders: {
        ...details.responseHeaders,
        'Content-Security-Policy': [
          electronIsDev
            ? `default-src ${customScheme}://\* 'unsafe-inline' devtools://\* https://\* 'unsafe-eval' http://\* data: ; style-src 'self' 'unsafe-inline' ${customScheme}://\* https://\* http://\* ws://\*`
            // : `default-src ${customScheme}://\* 'unsafe-inline' https://\* data: `,
            : `default-src ${customScheme}://\* 'unsafe-inline' data: https://\* ; style-src 'self' 'unsafe-inline' ${customScheme}://\* https://\*  ws://\*`

        ],
      },
    });
  });
}

Screenshot of CSP errors. I do not even know what is violating the rule at this point.

image