Response for preflight has invalid HTTP status code 403. Angular Laravel Passport
Response for preflight has invalid HTTP status code 403. Angular Laravel Passport
I have an Angular App that receives api requests from laravel application. I am using LAravel 5.6 and Passport 6.0. Everything is working fine on Local Environment. But When I uploaded it to My Apache2 server I had a problem with it. First I could only login because I didn't need to user the access token. but when I try to request another api I get message "unauthenticated". The problem happens with Post man to. I installed Barryvdh Laravel Cors: https://github.com/barryvdh/laravel-cors. I have added BarryvdhCorsHandleCors::class,
in Kernel file. I also tried to create cors file in the my config but no hopes. Although, I had the headers module enabled for apache2 and I had my headers rules in my .htaccess file. The only thing that solved my issue that I had to put the headers rules in my httpd. conf as follows
BarryvdhCorsHandleCors::class,
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPT$
Header always set Access-Control-Allow-Headers "origin, authorization, x-Re$
Header always set Access-Control-Max-Age: "3600".
Finally I solved the issue but now. I am getting error "Response for preflight has invalid HTTP status code 403"
in my angular app.but it is working fine with Postman now and I can get the requests. I have been in this problem over a month now and search all the issues and nothing solved the problem. On other hand it is working totally fine with mobile from the beginning. If anyone have similar problem let me know?
"Response for preflight has invalid HTTP status code 403"
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment