Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node:internal/errors:464 ErrorCaptureStackTrace(err);

When I was trying to add secure API keys in the .env file, I got this error:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-RapidAPI-Host"
    at ClientRequest.setHeader (node:_http_outgoing:579:3)
    at new ClientRequest (node:_http_client:256:14)
    at Object.request (node:https:353:10)

Below is my code:

const axios = require("axios");

const BASE_URL = `https://mashape-community-urban-dictionary.p.rapidapi.com`

module.exports = {
    getCompatibility: (yourSearch) => axios({
        method:"GET",
        url : BASE_URL + `/define`,
        headers: {
          'X-RapidAPI-Host': process.env.rapidapi_host,
          'X-RapidAPI-Key': process.env.Rrapidapi_key
        },
        params: {
            term: yourSearch
        }
    })
}

My env file:

rapidapi_host={my secure host}
rapidapi_key={my secure key}

Can anyone explain why that is happening?

like image 522
Qianying Huang Avatar asked Sep 16 '25 08:09

Qianying Huang


1 Answers

For me I solved this error just by putting the file extension in the import.

For example, instead of writing import { file } from "file", I wrote import { file } from "file.js" in all files.

like image 198
Lais Gomes Avatar answered Sep 17 '25 22:09

Lais Gomes