question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Right way to set up STRAPI_URL in .env

See original GitHub issue

How do I use STRAPI_URL ? I have tried the following:

File .env:

STRAPI_URL="http://localhost:1337"

File .env.production:

STRAPI_URL="https://my-app.herokuapp.com/"

In nuxt.config.js I have first tried to set env property and the new runtime config:

env: {
  STRAPI_URL: process.env.STRAPI_URL || 'http://localhost:1337',
},

publicRuntimeConfig: {
  STRAPI_URL: process.env.STRAPI_URL,
},

Then I have also tried the url option:

strapi: {
  url: process.env.STRAPI_URL || 'http://localhost:1337',
},

It doesn’t work, $strapi is always doing calls to localhost:1337.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Atinuxcommented, Nov 4, 2020

@luixal you don’t need to require(‘dotenv’), Nuxt does it for you.

@baermathias This is a valid solution, keep in my mind that you may expose sensitive information to git if this file is not gitignore

0reactions
luixalcommented, Nov 6, 2020

@Atinux right, it isn’t need. I would assure I had to add it once, but I can confirm it’s working without 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment configuration and variables - Strapi documentation
BROWSER, Open the admin panel in the browser after startup, Boolean, true ; ENV_PATH, Path to the file that contains your environment variables,...
Read more >
Right way to set up STRAPI_URL in .env · Issue #67 - GitHub
In nuxt.config.js I have first tried to set env property and the new runtime config: env: { STRAPI_URL ...
Read more >
Configuration
Your application configuration lives in the config folder. All the configuration files are loaded on startup and can be accessed through the configuration ......
Read more >
Strapi - Configure with environment variables - Stack Overflow
Looks like the only way is to use a hook. In my server.js file (I would move the config into it's own file...
Read more >
The Strapi Configuration Folder - Strapi /config - YouTube
Strapi 3.0.0 Stable Release introduces a new and simplified way to ... and give you an example of setting up multi- environment configuration ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found