nuxt-alt / proxy

An alternative module to @nuxtjs/proxy
MIT License
24 stars 5 forks source link

Argument of type ... is not assignable to parameter of type 'NuxtConfig'. #9

Closed cainenielsen closed 1 year ago

cainenielsen commented 1 year ago

I believe I have configured the module correctly, but I am receiving an error from TS. See below.

Related to the proxy key not being defined on type NuxtConfig.

Is this an issue with my project configuration? Is there a step I am missing? Should I attempt to extend NuxtConfig?

Argument of type '{ modules: string[]; proxy: { proxies: { '^//auth/.*': { target: string; changeOrigin: boolean; rewrite: (path: string) => string; }; }; }; }' is not assignable to parameter of type 'NuxtConfig'.
  Object literal may only specify known properties, and 'proxy' does not exist in type 'NuxtConfig'.ts(2345)
cainenielsen commented 1 year ago

I solved the issue.

For anyone else coming across this or similar issues. I learned that Nuxt comes shipped with a nuxt prepare command.

This command generates types based on the Nuxt configuration. These added definitions should fix issues like this.

When creating a new Nuxt project a postinstall script will be added to package.json that should run this command after every install. (npm i)

You can also run the command manually.

See here for more details. https://nuxt.com/docs/api/commands/prepare