[Vuejs]-Typescript Error assigning VITE_API_URL to axios' baseURL

4👍

You can augment ImportMetaEnv to add the type for any custom environment variables you’re using:

  1. In src/env.d.ts (create if needed), add the following code:

    /// <reference types="vite/client" />
    
    interface ImportMetaEnv {
      readonly VITE_API_URL: string
    }
    
  2. If using VS Code, you might need to restart the TypeScript server (or the IDE itself) for the types to be reloaded.

screenshot

👤tony19

Leave a comment