Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csp problems #1810

Open
gonojuarez opened this issue Mar 14, 2025 · 5 comments · May be fixed by #1816
Open

csp problems #1810

gonojuarez opened this issue Mar 14, 2025 · 5 comments · May be fixed by #1816
Assignees
Milestone

Comments

@gonojuarez
Copy link
Collaborator

gonojuarez commented Mar 14, 2025

Description
create a hotfix related to CSP in the developer environment.

  • Users in the dev environment can't connect the API because Windows rejects it.
  • the problem is related to the HTTP protocol in Windows 11.
@gonojuarez gonojuarez self-assigned this Mar 14, 2025
@gonojuarez gonojuarez changed the title Cors problems csp problems Mar 17, 2025
@gonojuarez
Copy link
Collaborator Author

I suggest removing from /public/index.html the label

 <meta http-equiv="Content-Security-Policy" content="
    default-src 'self'
        'unsafe-inline'
        'unsafe-eval'
        https://*
        wss://*.microsoft.com/cognitiveservices/
        blob:
        gap:
        data:;
    img-src * data:  filesystem:  blob:  ;
    ">

and implements a good csp with react
like us:

import { useEffect } from 'react';

const setupCSP = () => {
  // Detectar entorno
  const isDevelopment = process.env.NODE_ENV === 'development';

  const localHostSources = isDevelopment
    ? 'http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*'
    : '';

  const cspContent = `
    default-src 'self' https://app.cboard.io https://api.cboard.io ${localHostSources};
    script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.paypal.com https://www.sandbox.paypal.com ${localHostSources};
    style-src 'self' 'unsafe-inline' ${localHostSources};
    img-src * data: blob: filesystem:;
    connect-src 'self' https://api.cboard.io wss://*.microsoft.com/cognitiveservices/ https://*.paypal.com ${localHostSources};
    media-src 'self' blob: ${localHostSources};
    object-src 'none';
    frame-src 'self' https://www.paypal.com https://www.sandbox.paypal.com ${localHostSources};
    font-src 'self' data: ${localHostSources};
  `
    .replace(/\s+/g, ' ')
    .trim();

  // Añadir la meta tag dinámicamente
  const meta = document.createElement('meta');
  meta.httpEquiv = 'Content-Security-Policy';
  meta.content = cspContent;
  document.head.appendChild(meta);
};

//initializeAppInsights


// When running in Cordova, must use the HashRouter
const PlatformRouter = isCordova() ? HashRouter : BrowserRouter;

// Paypal settings

//render app
const renderApp = () => {
  if (isCordova()) {
    initCordovaPlugins();
  }
 //implements the CSP
  setupCSP();
 // render code
  ReactDOM.render(
    <Provider store={store}>
      <PersistGate persistor={persistor}>
        <PayPalScriptProvider options={paypalOptions}>
          <SpeechProvider>
            <LanguageProvider>
              <ThemeProvider>
                <SubscriptionProvider>
                  <PlatformRouter>
                    <DndProvider backend={TouchBackend} options={dndOptions}>
                      <Route path="/" component={App} />
                    </DndProvider>
                  </PlatformRouter>
                </SubscriptionProvider>
              </ThemeProvider>
            </LanguageProvider>
          </SpeechProvider>
        </PayPalScriptProvider>
      </PersistGate>
    </Provider>,
    document.getElementById('root')
  );
};

isCordova() ? onCordovaReady(renderApp) : renderApp();

@gonojuarez
Copy link
Collaborator Author

I found problems related to connecting with the araasac and other API links.
that implementations need a full testing

@RodriSanchez1 RodriSanchez1 added this to the 1.35.0 milestone Mar 18, 2025
@gonojuarez
Copy link
Collaborator Author

gonojuarez commented Mar 19, 2025

there is an explain about the csp

@gonojuarez gonojuarez linked a pull request Mar 20, 2025 that will close this issue
@RodriSanchez1 RodriSanchez1 reopened this Mar 20, 2025
@gonojuarez
Copy link
Collaborator Author

gonojuarez commented Mar 26, 2025

not pass the android testing, because lock internal files
return to in progress

@RodriSanchez1
Copy link
Collaborator

related #1183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants