Error 403 when receiving http post from another server - php

I'm implementing a payment method in PHP Laravel 5.6, and i'm supposed to receive an online notification through POST to an url i provide. It is getting Error 403, my POSTS from within the APP work completely fine.
As this POST comes from outside with no csrf, i've added my route on VerifyCSRF exceptions. but still it keeps saying 403.
I'm using Laravel 5.6 on AWS Elastic beanstalk on a load balancer, on top of this i use cloudflare.
web.php route
Route::post('/tpv/notificationOK', 'TPVController#order_notificationOK');
VerifyCsrfToken.php
protected $except = [
'tpv/notificationOK',
'https://www.pcmaker.es/tpv/notificationOK'
];
I expect to receive a POST and execute order_notificationOK function on /tpv/notificationOK URL but instead i'm getting "Server returned HTTP response code: 403 for URL: /tpv/notificationOK"
----------EDIT-------------
Just in case it can help someone, Cloudflare was blocking the POST request causing into an error 403, i just had to whitelist the ip where the POST came from and it works fine.

Related

Laravel api error 405 method not allowed + POST method received as GET by the server

i'm facing an issue with my Laravel api.
All my POST requests are getting 405 error (method not allowed) and are received as GET request by the server in production environment only.
Everything works perfectly fine in dev and local environment.
I'm developing with the version 5.8.* of Laravel on an nginx server.
Here is an example with my root for login:
Route::post('/login', 'Api\PassportController#login');
can someone help please ?

Laravel7 CORS : blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'

Use case: VueJS/Laravel app has inventory. Calling Magento2 using SOAP API to update Qty from VueJS/Laravel.
Error as shared below:
Access to XMLHttpRequest at
'http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx'
from origin 'http://192.168.0.x' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource.
Note: I am a beginner in this domain. I might be asking stupid questions. Please bear with me and requesting help here.
Tools/Apps used:
Laravel Framework 7.9.2 /Running on http://192.168.0.x
VueJS /Running on http://192.168.0.x
Magento2 /Running on http://xx.yyy.abc.123
Postman (Tool used to test SOAP API)
Debugging efforts:
URL http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx
Tried from postman: It works, Apended token into postmane and got the response.
Making AXIOS call from VueJS/Laravel application to Magento2:(Failed)
Origin: http://192.168.0.x
Magento2: http://xx.yyy.abc.123
axios.post("http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx",
{
})
.then((response) =>
{
console.log("response.data",response.data);
this.apiResponse = response.data;
//this.getproduct();
})
.catch(error =>
{
alert('ERROR GETCATEGORY!!!! No Data found');
console.log(error.response);
});
Checked for 2 days now about CORS error and found that this is enabled by default in Laravel 7. Not sure why I am seeing this error even after using Laravel 7. There are very few answers or solutions specific to VueJS with Laravel 7.
Question:
What does this error means. I thought it is just calling from webpage1 to webpage2, it does not seem to work.
Do I need to make any changes on my VueJS/Laravel application. Am I missing anything further.
Please do let me know if you need any more information to help me in this regards.
Thanks for your help.
Regards,
I had got the same CORS error while working on a Vue.js project. I finally solved this issue just today in the morning. You can resolve this either by building a proxy server or another way would be to disable the security settings of your browser (eg, CHROME) for accessing cross origin apis. Both these solutions had worked for me. The later solution is the easiest solutoion and does not require any mock server or a proxy server to be build. Both these solutions can be resolved at the front end.
You can disable your browser (CHROME) security settings for accessing apis out of the origin by typing the below command on the terminal:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security
After running the above command on your terminal, a new chrome window with security settings disabled will open up. Now, run your program (npm run serve / npm run dev) again and this time you will not get any CORS error and would be able to GET request using axios.
Hope this helps!

Laravel 5.4 Error 405 Method Not Allowed Error

I have Laravel 5.4 and VueJs application. When I run it in Localhost it was worked but now. I host in a server it gives the error GET > 405 Method Not Allowed Error. But GET requests are work fine. But this function I'm not using GET request. I using POST. But I giving this error. I have Installed CORS also. What can I do?
This is my POST Request in VueJS
this.$http.post("api/sendbooking",this.booking)
.then(function (response){
console.log(response)
})
This is api.php
Route::post('/sendbooking',[
'uses' => 'BookingController#setBooking'
]);
You're attempting to make a request that is unauthorized or otherwise not configured correctly. 405 means unauthorized HTTP verb in the request. Double check your route files that you can POST to the route you want to reach.
Anytime I see this is when I accidentally try to use GET on a POST route or similar.
And since you mentioned CORS, make sure all the required verbs are listed as allowed.

Postman returns "could not get any response" when hitting localhost laravel api route that I created

I'm just starting out with api's so pardon me if I'm missing something very obvious. I'm using xampp for my localhost and I've made this api route in Laravel Route::post('/register', 'RegisterController#register');
the name of my app is forum-api
this is the route that I'm using to hit the api through postman (I suspect that the problem is most likely this route):
http://localhost:8080/forum-api.app/api/register
whenever I send a request I get an error saying "Could not get any response"
I had this problem; this is what actually happenedI had typed in the url bar unknownweb.com/api/cars/23/parts/34
INSTEAD OF https://unknownweb.com/api/cars/23/parts/34

Nusoap library integration with codeigniter shows Unsupported HTTP response status 404 Not Found Error

I am using Nusoap library in codeigniter. My code works fine in localhost as well as on server before i make new folder for my testing purpose. But now in testing folder it gives error like this.
I'm receiving this Error:
HTTP Error: Unsupported HTTP response status 404 Not Found
(soapclient->response has contents of the response)
I have searched solution Here and Here but it shows that endpoint is not set for client. On my side, when I print my object it has the endpoint value... What do I do wrong?
I can't connect the URL(http://carvilshoe.cz.cc/index.wsdl.php?wsdl) from my web browser too. I think you have to check your WebService status is online.

Categories