openmina / mina-frontend

mina-frontend is an Angular web application that is showing node's progress, logs and statistics.
Other
1 stars 0 forks source link

CORS error while making graphql request to mina node #83

Open 0xMimir opened 9 months ago

0xMimir commented 9 months ago

I have frontend setup with local node, this is my src/environments/environment.ts:

import { MinaEnv } from '@shared/types/core/environment/mina-env.type';

export const environment: Readonly<MinaEnv> = {
  production: false,
  isVanilla: false,
  identifier: 'Local Network',
  globalConfig: {
    features: {
      dashboard: ['nodes', 'topology'],
      explorer: ['blocks', 'transactions', 'snark-pool', 'scan-state', 'snark-traces'],
      resources: ['system'],
      network: ['messages', 'connections', 'blocks', 'blocks-ipc'],
      tracing: ['overview', 'blocks'],
      benchmarks: ['wallets', 'transactions'],
      storage: ['accounts'],
      'snark-worker': ['dashboard', 'actions'],
      'web-node': ['wallet', 'peers', 'logs', 'state'],
    },
  },
  configs: [
    {
      name: 'local',
      graphql: 'http://localhost:3085',
      debugger: 'http://localhost:8000',
    }
  ],
};

After it start query to check latest height fails with CORS ERROR

I can query the node from it's graphql interface at http://localhost:3085/graphql so I don't think it is something with ocaml node. In network tab there is not Response or Response headers on this request. This is how request looks when copied as fetch

fetch("http://localhost:3085/graphql", {
  "headers": {
    "accept": "application/json, text/plain, */*",
    "content-type": "application/json",
    "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Brave\";v=\"120\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Linux\""
  },
  "referrer": "http://localhost:4200/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "{\"query\":\"\\n  query latestBlockHeight {\\n    bestChain(maxLength: 1) {\\n      protocolState {\\n        consensusState {\\n          slotSinceGenesis\\n        }\\n      }\\n    }\\n  }\\n\"}",
  "method": "POST",
  "mode": "cors",
  "credentials": "omit"
});

When this is ran in browser I get following error:

zone.js:1519 Uncaught TypeError: Failed to fetch
    at zone.js:1518:36
    at proto.<computed> (zone.js:973:24)
    at <anonymous>:1:7

Mina node has commit: bfd1009abdbee78979ff0343cc73a3480e862f58