Hi Team, I need some help here. I struggle to dis...
# gooddata-ui
s
Hi Team, I need some help here. I struggle to display insight of GoodData UI within a web app created with gooddata-create-gooddata-react-app by following this https://www.gooddata.com/developers/cloud-native/doc/cloud/getting-started/build-web-data-applications/ I followed the instructions to setup the backend and workspace value properly I am stuck between level 6 and 7, setting up CORS and Display some insights. and my setupProxy file looks like this
Copy code
const { createProxyMiddleware } = require("http-proxy-middleware");

require("@babel/register")({
  presets: ["@babel/preset-typescript", "@babel/preset-env"],
  plugins: ["add-module-exports"],
  extensions: [".ts", ".js"],
});

const constants = require("./constants.ts");

const domain = constants.backend;
module.exports = function (app) {
  app.use(
    "/api",
    createProxyMiddleware({
      changeOrigin: true,
      cookieDomainRewrite: "localhost",
      secure: false,
      target: domain,
      headers: {
        host: domain.replace(/^https:\/\//, ""),
        // This is essential for Tiger backends. To ensure 401 flies when not authenticated and using proxy
        "X-Requested-With": "XMLHttpRequest",
      },
      onProxyReq: function (proxyReq, _req, _res) {
        // changeOrigin: true does not work well for POST requests, so remove origin like this to be safe
        proxyReq.removeHeader("origin");
        proxyReq.setHeader("accept-encoding", "identity");
      },
    }),
  );
  app.use(
    "/*.html",
    createProxyMiddleware({
      changeOrigin: true,
      secure: false,
      target: domain,
    }),
  );
  app.use(
    "/packages/*.{js,css}",
    createProxyMiddleware({
      changeOrigin: true,
      secure: false,
      target: domain,
    }),
  );
};
f
Hi Sante, Thanks for the details and the screenshot you posted below! Now, from the error message, it appears as if CORS was not set up to allow the localhost origin. Have you followed the steps outlined in Enable CORS for an Organization on the GoodData Cloud instance you are connecting the app to?
s
Thanks you @Francisco Antunes for the reply. I have read this par but I was unsure which value to put for an allowed origin. (Also we are using trial version if that can help). Which value should I add for the origin?
j
Hi @SanteRek. If you’re trying to connect from localhost, it should look something like this:
The port is up to you.
s
Hey @Jan Rehanek Thanks for the info. The issue with this is that whenever I do that the app is continuously reloading.
j
Is there any clue in the browser’s console or the network tab to indicate why that is?
Well, this still looks like the same error with CORS. Could you check if the configuration is valid or show it here?