Adjustable and angular API

Asked

Viewed 140 times

2

I am trying to make a request using angular connecting to the REST API built in Laravel.

XMLHttpRequest cannot load http://localhost:8000/rest/v1/entidades/licitacoes. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 500.

I know that the API should set the header, However when testing with POSTMAN works normally. what may be happening?

1 answer

4


You need to configure the CORS headers for the request from the browser to work properly. All modern browsers make a request known as preflight before the requisition or posting of data itself, in order to check if it is possible to send them.

This Laravel package helps you set up CORS in your Laravel app: https://github.com/barryvdh/laravel-cors

Browser other questions tagged

You are not signed in. Login or sign up in order to post.