-1

enter image description hereI am running angular application on localhost:4200 while GraphQL are running using the following environment.

export const environment = {
  BASE_URL: 'https://iotech.ddns.net/',
  LOGIN_URL: 'https://iotech.ddns.net/',
  METRIC_VALUES_URL: `${'https://iotech.ddns.net/' + 'gql/'}v1/graphql`,
  REST_BASE_URL: ' https://iotech.ddns.net/config/api/v1/',
  production: true,
  hmr: false,
  staging: false,
  POLL_RATE: 10000
};

According to GraphQL it's mentioned the CORS are enabled but I am getting the error while accessing.I have also added the proxy.config.json but nothing help.

{
    "/gql/v1/graphql": {
      "target": "https://iotech.ddns.net/",
      "pathRewrite": { "^/api": "" },
      "secure": false
    },
    "logLevel": "debug"
  }

1 Answers1

0

If iotech.ddns.net is under your control and it is used as frontend api, you can add CORS header to allow localhost:4200 if not, you have to write your API server (by PHP, .net, python, node...), and call iotech.ddns.net from your server and return result to your frontend with cors headers.

Thanh Khánh
  • 621
  • 1
  • 9
  • 21