like-gold
like-gold11mo ago

Cannot use import.meta.env

Error: Property 'env' does not exist on type 'ImportMeta'
export default defineConfig({
plugins: [react()],
base: import.meta.env.VITE_APP_BASE_URL
});
export default defineConfig({
plugins: [react()],
base: import.meta.env.VITE_APP_BASE_URL
});
.env
VITE_APP_BASE_URLL=/my_api
VITE_APP_BASE_URLL=/my_api
3 Replies
kapa.ai
kapa.ai11mo ago
Hi @tads8799. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The information extracts provided do not contain a solution to the error you're encountering. However, it seems like you're trying to access environment variables in your configuration file. In the context of refine, environment variables are typically loaded from a .env.local file and accessed via process.env.YOUR_VARIABLE. Here's an example from the extracts:
export async function getServerSideProps() {
const response = await axios({
method: 'put',
url: process.env.API_URL,
header: {
Authorization: process.env.API_KEY
},
data: {
id: 12
}
});
}
export async function getServerSideProps() {
const response = await axios({
method: 'put',
url: process.env.API_URL,
header: {
Authorization: process.env.API_KEY
},
data: {
id: 12
}
});
}
In this example, API_URL and API_KEY are environment variables loaded from a .env.local file. For more detailed information, you might find the refine documentation (https://refine.dev/docs) helpful. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai11mo ago
<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below
like-gold
like-gold11mo ago
It works now