Unable to call the INSEE API in the deployed version of the Angular project with the proxy

Discussão em 'Angular' iniciado por AkizaS, Fevereiro 7, 2025.

  1. AkizaS

    AkizaS Guest

    When I deploy my project on the test site it is impossible to retrieve data from the API. Locally the problem does not arise.

    api.siren.service.ts:29 Erreur API détectée:
    HttpErrorResponse {headers: _HttpHeaders, status: 200, statusText: 'OK', url: 'http://xxx.xxx.net::8000/xxxx/', ok: false, …}
    (anonymous) @ api.siren.service.ts:29
    Zone - XMLHttpRequest.addEventListener:load
    searchSiret @ header.component.ts:1122
    HeaderComponent_div_55_div_17_Template_button_click_2_listener @ header.component.html:548
    Zone - HTMLButtonElement.addEventListener:click
    HeaderComponent_div_55_div_17_Template @ header.component.html:548
    HeaderComponent_div_55_Template @ header.component.html:543
    Zone - Promise.then
    (anonymous) @ main.ts:5


    header.component.ts:1132 Erreur API SIREN: Error: Erreur API (HTTP 200): Http failure during parsing for http://xxx.xxx.net:8000/xxx/
    at api.siren.service.ts:39:37
    at _Observable.init [as _subscribe] (throwError.js:5:51)
    at _Observable._trySubscribe (Observable.js:37:25)
    at Observable.js:31:30
    at errorContext (errorContext.js:19:9)
    at _Observable.subscribe (Observable.js:22:9)
    at catchError.js:14:31
    at OperatorSubscriber._error (OperatorSubscriber.js:23:21)
    at OperatorSubscriber.error (Subscriber.js:40:18)
    at OperatorSubscriber._error (Subscriber.js:64:30)


    {
    "/api-sirene/": {
    "target": "https://api.insee.fr",
    "secure": true,
    "changeOrigin": true,
    "logLevel": "debug",
    "pathRewrite": {
    "^/api-sirene": "/api-sirene/3.11/siren"
    }
    }
    }


    I thought I needed the SSL certificate, but even with that nothing changed. I think the problem may be with the proxy configuration. I thank you in advance for your help.

    Continue reading...

Compartilhe esta Página