''siteUrl can't be localhost' when deploying to Netlify

I tried to build a blog using gatsby and ghost. In the local server, it works fine. but when I run this command gatsby build in my local computer, it gives me the same error below.

The following is the log file of the error when deploying the gatsby-ghost site from my GitHub repository to Netlify.

After that,as a solution , I tried changing the both apiUrl values of development and production to myNetlifyAppUrl. ( format : https://foor-bar-foo.netlify.app/ ).It did not help me either.

I don't know what it meant by the siteUrl, and in which file should I change it.

Please consider looking into this matter. Thanks in advance!

4:44:50 PM: ────────────────────────────────────────────────────────────────
4:44:50 PM:   1. build.command from netlify.toml                            
4:44:50 PM: ────────────────────────────────────────────────────────────────
4:44:50 PM: ​
4:44:50 PM: $ NODE_ENV=production gatsby build
4:44:52 PM: error We encountered an error while trying to load your site's gatsby-config. Please fix the error and try again.
4:44:52 PM: 
4:44:52 PM:   Error: siteUrl can't be localhost and needs to be configured in siteConfig. Ch  eck the README.
  
4:44:52 PM:   - gatsby-config.js:26 Object.<anonymous>
4:44:52 PM:     /opt/build/repo/gatsby-config.js:26:11
4:44:52 PM:   
4:44:52 PM:   - v8-compile-cache.js:192 Module._compile
4:44:52 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:192:30
4:44:52 PM:   
4:44:52 PM:   - loader.js:1114 Object.Module._extensions..js
4:44:52 PM:     internal/modules/cjs/loader.js:1114:10
4:44:52 PM:   
4:44:52 PM:   - loader.js:950 Module.load
4:44:52 PM:     internal/modules/cjs/loader.js:950:32
4:44:52 PM:   
4:44:52 PM:   - loader.js:790 Function.Module._load
4:44:52 PM:     internal/modules/cjs/loader.js:790:12
4:44:52 PM:   
4:44:52 PM:   - loader.js:974 Module.require
4:44:52 PM:     internal/modules/cjs/loader.js:974:19
4:44:52 PM:   
4:44:52 PM:   - v8-compile-cache.js:159 require
4:44:52 PM:     [repo]/[v8-compile-cache]/v8-compile-cache.js:159:20
4:44:52 PM:   
4:44:52 PM:   - get-config-file.ts:30 getConfigFile
4:44:52 PM:     [repo]/[gatsby]/src/bootstrap/get-config-file.ts:30:20
4:44:52 PM:   
4:44:52 PM:   - load-config-and-plugins.ts:26 loadConfigAndPlugins
4:44:52 PM:     [repo]/[gatsby]/src/bootstrap/load-config-and-plugins.ts:26:50
4:44:52 PM:   
4:44:52 PM:   - initialize.ts:143 initialize
4:44:52 PM:     [repo]/[gatsby]/src/services/initialize.ts:143:46
4:44:52 PM:   
4:44:52 PM:   - index.ts:47 bootstrap
4:44:52 PM:     [repo]/[gatsby]/src/bootstrap/index.ts:47:15
4:44:52 PM:   
4:44:52 PM:   - build.ts:87 build
4:44:52 PM:     [repo]/[gatsby]/src/commands/build.ts:87:59
4:44:52 PM:   
4:44:52 PM: 
4:44:52 PM: not finished open and validate gatsby-configs, load plugins - 0.152s
4:44:52 PM: ​
4:44:52 PM: ────────────────────────────────────────────────────────────────
4:44:52 PM:   "build.command" failed                                        
4:44:52 PM: ────────────────────────────────────────────────────────────────```





Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source