Reputation: 2499
Everytime i navigate to the relativ path i get following error:
TypeError: Parameter "url" must be a string, not undefined
at Url.parse (url.js:103:11)
My get method looks like:
app.get('/v1/locations', (req, res) => {
const fixieUrl = url.parse(process.env.FIXIE_URL);
const requestedUrl= url.parse('api.clashofclans.com' + req.path);
const options = {
host: fixieUrl.hostname,
port: fixieUrl.port,
path: requestedUrl.href,
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer **token**',
'Proxy-Authorization': `Basic ${new Buffer(fixieUrl.auth).toString('base64')}`
}
};
I definately added the .env file with the FIXIE_URL so what could it be?
Upvotes: 0
Views: 1057
Reputation: 1583
base on your comment since process.env.FIXIE_URL
is undefined. It means the env variable is not set. so to fix this you can do this when start ur node app
export FIXIE_URL='yourUrl' npm start // or however you start ur node app
or add this yourUrl in a constant file which you load it from there.
or save export FIXIE_URL='yourUrl'
in your OS profile
Upvotes: 0
Reputation: 5542
Try req.url
instead of process.env.FIXIE_URL
Update
It's better to separate these.
In the .env
file set, and use these in url.js
:
FIXIE_URL_HOST=someUrl
FIXIE_URL_PORT=80
Upvotes: 2