1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

net::ERR_FAILED zone-evergreen.js:2952

Discussão em 'Angular' iniciado por Dzak, Outubro 16, 2024 às 07:42.

  1. Dzak

    Dzak Guest

    Using Angular 7 as front-end and Nodejs as back-end.

    I deployed a web site at Amazon-web-service using IIS and when I doing API requests to the server everything works just fine.

    But when a client from China is trying to use the same website and send the same API he gets a No 'Access-Control-Allow-Origin' header is presented on the requested resource

    other then that error, he receives another error: POST http:... net::ERR_FAILED zone-evergreen.js:2952

    what is the zone-evergreen.js and how does it affects the cors policy?

    P.S.

    when the client browsing his mobile smartphone the API is successfully sent. the problem is happening on his computer device.

    here is the server code (node.js):

    const express = require('express');
    const cors = require('cors');


    app.use(cors());
    app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.append('Access-Control-Allow-Headers', 'Content-Type');
    next();
    })


    here is the client sending the API request (Angular 7):

    public saveData(data: any): Observable<any> {
    const httpOptions = {
    headers: new HttpHeaders({
    'Content-Type': 'application/json',
    }),
    };

    return this.http.post(this.baseUrl + this.apiName, JSON.stringify(data), httpOptions);
    }


    the error: [​IMG]

    Continue reading...

Compartilhe esta Página