Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing IONOS cloud, parsing headers, cURL, node
# This approach works. ✅
# The idea is possibly cURL is tolerant to invalid headers.
# How to test:
# 1. Install cURL https://curl.haxx.se/
# 2. In your terminal copy and paste:
curl -v -H 'X-TOKEN: 1234' 'https://cloudpanel-api.ionos.com/v1/servers'
/*
This does not work because nodejs cannot parse the headers. 🐛
How to reproduce:
1. Install nodejs https://nodejs.org/de/
https://nodejs.org/en/
2a. Try to you use your company's module with node: https://github.com/1and1/oneandone-cloudserver-sdk-nodejs
2b. `npm install superagent` and run this script with node
*/
const superagent = require("superagent");
const endpointUrl = "https://cloudpanel-api.ionos.com/v1";
const token = "1234";
superagent
.get("https://cloudpanel-api.ionos.com/v1/servers")
.set("X-TOKEN", token)
.type("json")
.accept("json")
.then(res => console.log("res", res))
.catch(err => console.error("err", err)); // ⬅️⚠️ it will not parse headers
@tcrowe

This comment has been minimized.

Copy link
Owner Author

tcrowe commented Jan 17, 2020

In the end we discovered that it was node v12 that would not handle these headers. The solution was downgrade to v10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.