1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Access to XMLHttpRequest has been blocked by CORS policy

Discussão em 'Angular' iniciado por rikg93, Junho 3, 2025.

  1. rikg93

    rikg93 Guest

    I've a problem when I try to do PATCH request in an angular 7 web application. In my backend I have:

    app.use((req, res, next) => {
    res.set({
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Methods": "*",
    "Access-Control-Allow-Headers": "'Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token'",
    });

    next();
    });


    In my frontend service, I've:

    patchEntity(ent: any, id) {
    let headers = new Headers({ 'Content-Type': '*' });
    let options = new RequestOptions({ headers: headers });
    return this.http.patch('my_url', ent).map((res: Response) => res.json());
    };


    The error is:

    Access to XMLHttpRequest at 'my_url' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.


    What can I to do? Thanks.

    Continue reading...

Compartilhe esta Página