Coder Social home page Coder Social logo

Comments (4)

Chuloo avatar Chuloo commented on September 14, 2024

could you check if it's a valid cloud name? You can just use a sample Cloudinary image URL on your browser. Also, print the .env data in development anywhere to see if the value is passed. Let me know if all these are positive while I try to reproduce it.

from gatsby-source-cloudinary.

indefinit avatar indefinit commented on September 14, 2024

I think I figured out where the problem is. It seems to be related to the gatsby-config.js. In the plugin documentation it recommends placing the cloudinary api config in a .env.development file, and then in gatsby-config.js:

// Load the environment variables.
require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`,
});

but if I run the gatsby build command the node env is no longer looking for development. Renaming .env.development to .env, and removing the NODE_ENV specificity prevents the error during gatsby build:

require('dotenv').config({
  path: `.env`,
});

But I'm not sure if this is an ideal solution, if a user wants to specify different .env variables at build and develop stages. Is there a better way to solve for this?

from gatsby-source-cloudinary.

Chuloo avatar Chuloo commented on September 14, 2024

Yes, that's the solution. Typically you may want to maintain different .env definitions for your environments. If it's the same .env config across dev and production then you can just use .env instead of .env.development or .env.production.

You can add a .env.development file too with the dev variables if you like.

Also, to specify different ENV then you can add the NODE_ENV config in your scripts object in package.json. Something like

"build": "NODE_ENV=production gatsby build"

Replace the NODE_ENV value for the dev command.

from gatsby-source-cloudinary.

indefinit avatar indefinit commented on September 14, 2024

Ah ok great thanks for the suggestion!

from gatsby-source-cloudinary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.