I have a backend that I would like to connect to and I would like to use the runtimeConfig to define the base url. For some reason, I can't get it working... I've read all of the nuxt docs and looked at stack overflow, I don't understand what I'm doing wrong. Here is my code:
(nuxt.config.ts)
runtimeConfig: {
// Private keys
public: {
// Public keys
API_BASE_URL: process.env.NODE_ENV === 'production' ? 'https://example.com' : 'http://localhost:8000'
}
}
(page.vue)
<script setup>
const config = useRuntimeConfig();
console.log(config.API_BASE_URL);
</script>
The result is that the console returns "undefined". I am running nuxt3, and running this code in a dev env, so I would expect the console to output 'http://localhost:8000'