Getting Error: getaddrinfo ENOTFOUND on Vue build

334 Views Asked by At

I'm using Vuepress 2 with Vue3 and a Vite bundler.

My markdown pages contain a simple component, whose job it is to fetch resources on other endpoints, It looks something like this:

export default defineComponent({
  name: 'MyComponent',
  components: {
    JsonViewer,
  },
  props: {
    serviceName: String,
    env: String,
  },
  async setup(props, ctx) {
    let message: any;
    const { serviceName } = props;
    const endpoint = currentEnv[serviceName];
    if (!endpoint) {
      return {
        message: { service: 'unknown' },
      };
    }
    message = (
      await axios.get(endpoint)
    ).data;
    return {
      message,
    };
  },
});

When I'm serving it locally thru the dev command, I have no issues and axios is making its requests as expected.

However, when I'm building the Vue app, I'm getting a Error: getaddrinfo ENOTFOUND www.api.techlab.localhost at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)

The endpoint I'm trying to reach is a local endpoint, which shouldn't be a problem for the production build.

What do you recommend? How do I bypass this error?

TIA

0

There are 0 best solutions below