Hi, I'm trying to integrate gooddata-ui in my angu...
# gooddata-ui
m
Hi, I'm trying to integrate gooddata-ui in my angular project, i'm getting this error: Access to XMLHttpRequest at 'https://marwantest.on.gooddata.com/api/actions/workspaces/...../execution/afm/execute' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. I tried the following: ā€¢ add proxy config but it didn't work for angular ā€¢ token authentication provider but it's not mentioned how to get ENV_VARIABLE_WITH_TOKEN ā€¢ tried the api /gdc/domains/{domain_name}/securitySettings/allowedOrigins/add with "http://localhost:4200" in items body but i'm getting
Copy code
{
  "error": {
    "errorClass": "BadRequestHttpException",
    "trace": "",
    "message": "Trying to insert malformed origin",
    "component": "Webapp",
    "errorId": "c01b5c48-2ebe-4a2a-ab2a-de7c3376f23b",
    "errorCode": "gdc.http.client.status.400",
    "parameters": []
  }
}
b
hello @Mohammad Zahr, allowed origin in format http://localhost:4200 is incorrect. First, it needs to be https and second, it needs to have at least 2 levels of domains. You can use i.e. https://local.test:4200. It's mentioned in our documentation here: https://sdk.gooddata.com/gooddata-ui/docs/platform_cors.html#step-2-configure-cors
furthermore, the API you are calling (/api/actions/workspaces/...../execution/afm/execute) seems to be related to GoodData.CN, while everything else suggests that you are using our hosted platofrm
m
b
m
After checking with my team it appeared that we are using the hosted platform and not CN. So i followed this link https://sdk.gooddata.com/gooddata-ui/docs/platform_cors.html#use-a-proxy and added the proxy file but it is not working in angular. Any suggestions ?
b
and is it working without angular?
we have a guide on how to set up gd.ui in angular here
m
Yeah i followed this guide and did as mentioned but i'm getting CORS ERROR. So i added the proxy.js file as mentioned in documentation but i think it only works for react and in my case it is angular.
b
@Jiri Zajic any idea please on how to do it with angular?
m
It's ok i fixed it by using localtunnel to get https url and added this url to allowedOrigins through the api. It works now, thanks.
šŸ™Œ 2
šŸ‘ 2