I'm using a node server that uses Request to hit a different server. The servers are in the same internal environment and have no connection restrictions, such as firewall or auth. However, whenever I try send a POST request from one to another, I get this error from Request.js:
Request resp: {
"pathname": "/testSocket",
"path": "/testSocket",
"body": "There was a problem with your request. Error code 13",
"href": "{hidden for privacy}"
Request body: "There was a problem with your request. Error code 13"
Does anyone know what Error Code 13 means in this context? I can't find any Node, Express, or Request documentation that explains it.
Related
I have followed the tutorials for adapting passport authentication strategies to Loopback 4, and have successfully gotten passport-http to work. But, when trying to get passport-ldapauth to work with loopback 4, I am consistently getting the following error Http response (using postman):
{
"error": {
"statusCode": 401,
"name": "UnauthorizedError",
"message": {
"message": "Missing credentials"
}
}
}
I have confirmed the online LDAP test server works with my setup (used a plain Express app with passport-ldapauth, with total success). Using the same LDAP config in Loopback 4, however, produces the above error.
My test Loopback app is here: https://replit.com/#woff2/CarefulGreenBits
It seems to me that I am doing something wrong with passing the verifyFn in to the AuthenticationStragegy.
Can anyone see what I am doing wrong? I have been at this for three or four days now!
It would be of great benefit to the community to solve this. I have seen many people online wanting the same auth method to work in Loopback over the past week.
UPDATE: I've narrowed it down to the request body not being processed. Whether the request body contains the username/password pair or not, the same 'Missing credentials' error results.
I found out that the username/password tuple must be passed as params on the http request. This information was contained in source-code comments of the passport-ldapauth package. Note however that when using passport-ldapauth with Express framework, passing the tuple in the request body does work.
I am writing an API in Nest, and when I try to test for a certain error being thrown on my client's side using Swagger UI, I get the response I expect. I've written an exception filter to customize my error messages.
`{
"statusCode": 403,
"error": "Duplicate entry '1' for key 'cameras.PRIMARY'",
"path": "cameras",
"method": "POST",
"timeStamp": "2022-06-24T23:24:57.843Z"
}`
But when I run the same action through my test case, my response is:
Received: {"message": "Internal server error", "statusCode": 500}
My actions on the API are completely equivalent, and yet I get two separate results depending on if I do it manually or if I do it from my test suite. What could possibly be causing this?
Forgive me if this has been solved, I’ve looked through every past related question I could find and was not able to get a working solution.
I’m building a small Figma plugin using javascript to allow users to create tickets in JIRA from Figma. Since Figma effectively runs as a browser-based application, following the advice of past questions on here I am doing the request through a cors anywhere proxy (Heroku), following the advice of the first answer in a stack overflow post.
I’m using the following code and POST request to do this.
const basicAuth = buffer__WEBPACK_IMPORTED_MODULE_6__.Buffer.from(username + ‘:’ + password).toString(‘base64’);
// where password is the API token
const bodyData = { "fields": { "summary": "Main order flow broken", "issuetype": { "id": "10000" }, "project": { "id": "10000" }, "customfield_10011" : "Test" } };
fetch(https://fierce-spire-09192.herokuapp.com/https://${companyName}.atlassian.net/rest/api/3/issue, {
method: ‘POST’,
headers: {
‘Authorization’: ${basicAuth},
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘X-Atlassian-Token’: ‘nocheck’
},
body: bodyData
})
However, I’m getting the following error when I make the request.
POST https://fierce-spire-09192.herokuapp.com/https://flighthealthtest.atlassian.net/rest/api/3/issue 403 (Forbidden)
Response: 403 Forbidden
XSRF check failed
When I try the non-proxied URL (removing the heroku app URL from the beginning, so just "https://flighthealthtest.atlassian.net/rest/api/3/issue") in Postman and make the same POST request, it works perfectly. When I use the proxied URL in Postman, it does not work, and produces:
“Missing required request header. Must specify one of: origin,x-requested-with”.
Does anyone have ideas as to how I can resolve this? Thanks so much!
Am trying to make a post request to https://app.getswift.co/api/public/v2/deliveries using requests library and I get the following error
HTTPSConnectionPool(host='app.getswift.co', port=443): Max retries exceeded with url: /api/public/v2/deliveries (Caused by SSLError(CertificateError("hostname 'app.getswift.co' doesn't match either of '*.my_domain.ai', 'another.my_domain.ai'),))
This is the request I make.
headers = {
'Content-Type': 'application/json',
}
data = {
"apiKey": "my-api-key",
"booking": {
"pickupDetail": {
"name": "Rupert 1",
"phone": "1234567890",
"address": "112 luscombe st, brunswick, melbourne"
},
"dropoffDetail": {
"name": "Igor 2",
"phone": "0987654321",
"address": "105 collins st, 3000"
}
}
}
requests.post("https://app.getswift.co/api/public/v2/deliveries", headers=headers, json=data)
I tested the same code on my local, python shell and even making a postman request, it works perfectly fine. The problem comes when I try to push the same code to ec2 server and make the post request call.
I tried using verify=False to see if it works(even though I know the security consequences) but instead, I get "404 Not found".
This is what I see on my ec2 logs
Not Found: /api/public/v2/deliveries
HTTP POST /api/public/v2/deliveries 404 [0.01, 127.0.0.1:57840]
https://app.getswift.co:443 "POST /api/public/v2/deliveries HTTP/1.1" 404 None
I'll be grateful to any help.
It's hard to tell without accessing the exact page, but could you add the other headers such as User-Agent and the cookies=cookies? I think the page might be checking for authentication and you are not properly authenticating.
Otherwise, it could be also be that the ec2 server is behind a proxy/vpn like AWS servers can be. In that case, you can try to trust the environment.
s = requests.Session()
s.trust_env = False
response = s.get("https://app.getswift.co/api/public/v2/deliveries", headers=headers, json=data)
If it doesn't work then the API might simply be blocking your ec2 server. Try another making a ec2 in another region or use another VPS and see if it works.
Update: Fixed. It looks like the request was coming back as a 503 (as it should), then my app refreshed and displayed the non-error message: "Fetch failed loading". I just wasn't seeing the response because of the refresh.
I am not able to make a fetch request from my locally-hosted Create-React-App to my Heroku-hosted Node server.
My Node server has CORS enabled. If I make a POST request via Postman, I get an appropriate response (503, because currently there is no database hooked up, so the data is not being saved. If I should be sending back a different response, let me know). My Postman request has 'application/json' as the content-type, no authorization, and a body of { "rating": "5", "zipcode": "0" }.
However, when I make a POST request from my React app, I get a message in my console: "Fetch failed loading: OPTIONS "https://shielded-gorge-69158.herokuapp.com/feedback"." There is no associated error, only the message. There is no information about the request in my Network panel.
The fetch request works when I do it locally, from localhost:3000 (my app) to localhost:5000 (my server). It only fails when I try to make the request to the (otherwise identical) server hosted on Heroku.
This is what the fetch request looks like:
return fetch('https://shielded-gorge-69158.herokuapp.com/feedback', {
method: 'POST',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({ rating: userRating, zipcode: userZip })
}).then(res => {
if (!res.ok) {
throw new Error('Error:', res.statusText);
}
return res;
}).catch(err => console.error(err));
Edit: I'm continuing to research and it seems like Postman shouldn't/doesn't make preflight requests (https://github.com/postmanlabs/postman-app-support/issues/2845). So perhaps that is the issue — but why would the request be working when my server is local, but not when it is hosted on Heroku?
use 'Content-Type' instead of 'Content-type'.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests
https://fetch.spec.whatwg.org/#cors-safelisted-request-header
Explanation: when you use incorrect case then it is considered as a custom header and hence, a preflight request is sent in such cases. Now if OPTIONS request is implemented on server with correct cors spec then next POST will be sent, else it wont be sent and request will fail. More on this in above links.