3
I am trying to implement an integration of Angular 8 with the billet generating api of pay-off. Making the request by POSTMAN, I can generate without problems, by angular I am blocked by CORS.
follows the Decree
boletoGenerate(body: Boleto): Observable<any>{
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE'
})
}
return this.http.post<Boleto>(this.url, body, httpOptions).pipe();
}
I tried with and without setting the header, and the result was the same. Has anyone had this problem or knows how to fix ?
You can open Chrome with the --disable-web-security parameter. You can create a localhost certificate, it probably only allows req https. See the Sponse headers of the request.
– Ulric Merguiço
I contacted Pagseguro, they informed me that I need to implement this functionality in the backend. So in order for me to be able to implement this functionality that I want in the frontend, I’m going to need to do a request flow more or less like this: Frontend creates request -> Backend forwardthis request -> Pagseguro returns boleto -> Backend returns boleto -> Frontend captures the generated boleto
– Matheus Barbosa