Sudden Axios Error not properly sending parameters - axios

April 26 2022 The system that we are working is suddenly not working, I found out that the request data from frontend to backend suddenly became weird.
The regular request
array ( 'email' => 'xxxxx+1#gmail.com', 'password' => 12341234, )
When running Axios:
When I tried to use Ajax, the request is the normal one. However we are using axios for the majority of the project. Is someone else having the same error?
using the script: https://unpkg.com/axios/dist/axios.min.js

Related

Magento 2 - Custom rest api endpoint for PDF download - net::ERR_HTTP2_PROTOCOL_ERROR 200

I have created custom rest api endpoint in magento for downloading pdf file.
When testing it locally: From separate react JS project I am sending request to that endpoint and file is downloaded successfuly. http/1.1 protocol is used (checked in google chrome dev tools, network tab).
After deployment to staging servers, when I try to make request between staging servers from reactJS project to magento2 project, then upon sending request it takes 30-40 seconds without getting any response and then error is shown in console. There is not anything in the error logs. http2 protocol is used (not sure if that can be a reason for issue).
Failed to fetch - net::ERR_HTTP2_PROTOCOL_ERROR 200
Here is the piece of php code for downloading pdf file:
...
$filename = $outputFileName . time() . '.' . $extension;
$directoryTmpWrite = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$directoryTmpWrite->writeFile($filename, $fileContent);
return $this->fileFactory->create(
$outputFileName . '.' . $extension,
[
'type' => 'filename',
'value' => $filename,
'rm' => true,
],
DirectoryList::TMP, //basedir
'application/octet-stream',
''
);
How I resolved my issue?
I had to turn on output buffering in php in magento, to ensure that no output has been sent from a script and instead of that output has been store to a buffer and then sent all together from a script when script execution is finished.
So ob_start() fixed my issue. Right before return statement.

Unexpectedly redirecting to root address when request URL has special character in it

I'm facing the issue after upgrading server to RHEL 8.
Here is a php script I wrote to fetch the param:
<?php
if (isset($_GET)) {
echo $_GET['data'];
}
Now:
When I request to the server like: https://example.com?data=test
It prints 'test' perfectly
But, when I request to the server like: https://example.com?data="<title>test</title>"
It redirects to https://example.com and print nothing
Can anyone suggest a solution?

Binance::API: can't connect to the exchange

I'm an algo-trader and Perl fan.
I want to create a client which connects to Binance Future Testnet and i decided to exploit the Binance API module developed for Perl.
Once the Binance::API module was installed (no errors or warnings occurred there) i dived into my script first lines of code as follows:
#!/bin/perl
use Binance::API;
#API di Binance-Testnet
my $api = Binance::API->new(
apiKey => 'my api',
secretKey => 'my secret key',
);
$api->account();
$api->exchange_info();
API KEY and SECRET KEY are taken from my Binance Future Testnet Account (freely available for all users), succesfully used via tradingview and its Pine script tool.
Unfortunatly i got the following error:
[Binance::API::Request::_exec] Unsuccessful request.
Status => 401,
Content => {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} at C:/Strawberry/perl/site/lib/Binance/API/Request.pm line 107.
[Binance::API::Request::_exec] Unsuccessful request.
Status => 404,
Content => <html><body><h2>404 Not found</h2></body></html> at C:/Strawberry/perl/site/lib/Binance/API/Request.pm line 107.
Any idea on what went wrong with this? I don't want to use Python or C++ as I love Perl and its versatility.
If you look at Binance::API source code, you can see this module developed for Spot market. not Futures.
https://github.com/taskula/binance-perl-api/blob/master/lib/Binance/Constants.pm
BEGIN {
%constants = (
BASE_URL => $ENV{BINANCE_API_BASE_URL} || 'https://api.binance.com', #this endpoint is for spot
DEBUG => $ENV{BINANCE_API_DEBUG} || 0,
);
}
for Spot Testnet you can get API KEY from here:
https://binance-docs.github.io/apidocs/spot/en/#enabling-accounts
I think you may get confused with spot and futures. There are 4 different base URL for different markets:
Spot Production site: https://api.binance.com
Spot Testnet site: https://testnet.binance.vision
Futures Production site: https://fapi.binance.com
Futures Testnet site: https://testnet.binancefuture.com

Connecting Aurelia with backend API

Context: I'm starting a new project for my company. It's been many years since I've done some web development and decided to build it using the latest platforms (so I'm a still new to all of this).
Current stack:
Aurelia frontend (running on localhost:9000)
Backend REST API using ExpressJS (running on localhost:8000)
PostGreSQL database running on AWS, providing data for the backend
Question: I can't seem to connect my frontend with my backend properly.
Here is my code:
import {inject} from "aurelia-framework";
import {HttpClient} from "aurelia-http-client";
#inject(HttpClient)
export class Login {
constructor(httpClient){
this.http = httpClient;
}
signIn() {
const url = 'http://localhost:8000/api/user/demo/test';
this.http
.get(url)
.then(data => {
console.log("data");
console.log(data);
})
.catch(error => {
console.log('Error getting ' + url);
console.log(error);
});
};
}
This always end up in the catch block, with a "response: ProgressEvent"
If I put the url in the browser I get a proper JSON:
{"status":"success","data":[],"message":"Retrieved ALL users"}
The code above only works for 'local' content, i.e. localhost:9000. As soon as I need content from somewhere else I get this error. What am I missing?
I think that CORS is not allowing you to access localhost:8000 from localhost:9000. To solve this, you should enable your ExpressJS server to accept CORS requests from localhost:9000 (or all hosts using a wildcard "*").
Look into these resources:
https://enable-cors.org/server_expressjs.html
https://github.com/expressjs/cors
Or search Google for 'expressJS cors'.

Express Checkout Digital Goods : Proxy Error on sandbox.paypal.com/incontext

I have a Flash website. When I want to use Paypal Express Checkout with Digital Goods, I call this javascript code :
dg = new PAYPAL.apps.DGFlow();
dg.startFlow("http://mydomain.com/setup.php");
setup.php calls SetExpressCheckoutPayment function and redirect to https://www.sandbox.paypal.com/incontext?token=...&useraction=commit
With Firebug I can see this address returns a 302, and redirects to https://www.sandbox.paypal.com/webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow?exp_type=&cookiesBlocked=&token=...&useraction=commit
This adress returns also a 302 and redirects to https://www.sandbox.paypal.com/webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow?execution=e1s1
Here it hangs for several minutes and ends with this error message :
Proxy Error
The proxy server could not handle the request GET /webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow.
Reason: Error during SSL Handshake with remote server
I started to get this error sometimes last week, and I have it every time today.
It happens on my MAMP environment and on my website.
I don't have SSL certificate but I didn't last week and it was not a problem.
Do you know anything about this error message ?
Edit
I tried with Opera, proxyError comes at a different step : https://www.sandbox.paypal.com/webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow?execution=e1s4
And once this morning on Firefox I had another Proxy Error after the first redirection :
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow.
Reason: Error reading from remote server
I don't have the Proxy Error anymore since yesterday. I didn't change anything so it seems PayPal servers are unstable...
I'm having the same issue since Sunday evening (sorry that I can't post this as a comment, don't have enough reputation yet).
I'm on LiquidWeb shared hosting, using the Merchant SDK ( https://github.com/paypal/merchant-sdk-php ). I was on merchant-sdk-php-2.1.96 when the errors began, and tried upgrading to merchant-sdk-php-2.2.98 but now it is worse (won't even do the first redirect, which is confusing). My code is server side, but getting the timeout and proxy error at the same urls:
$setECResponse = $PayPal_service->SetExpressCheckout($setECReq);
if($setECResponse->Ack == 'Success') {
$token = $setECResponse->Token;
$payPalURL = 'https://www.sandbox.paypal.com/incontext?token=' . $token;
$this->Redirect($payPalURL);
}