stencil-cli icon indicating copy to clipboard operation
stencil-cli copied to clipboard

No API host found in config file

Open BC-AdamWard opened this issue 2 years ago • 11 comments

No api host found in config file, falling back to https://api.bigcommerce.com/. You may need to run 'stencil init' again.

Looks very similar to https://github.com/bigcommerce/stencil-cli/issues/844

Running stencil init -h https://api.bigcommerce.com/ solved for me.

Expected behavior

Stencil start throws no errors

Actual behavior

After running Stencil Start we receive a message of:

No api host found in config file, falling back to https://api.bigcommerce.com/. You may need to run 'stencil init' again.

Running Stencil init again does not resolve the issue

Steps to reproduce behavior

Environment

Stencil-cli version stencil --version: 6.0.0

Node version node -v: 14.20.0

NPM version npm -v:6.14.17

OS: MacS Monterey version 12.6

BC-AdamWard avatar Dec 21 '22 23:12 BC-AdamWard

Hi @BC-AdamWard, do yo mind to provide screenshots for the errors you had?

jairo-bc avatar Dec 22 '22 15:12 jairo-bc

Hey Jairo,

Error on Stencil Start - image

It does still launch but after that it seems some updates to the theme files do not get reflected in Browsersync appropriately.

The error also pops up on stencil push, but the file seems to be pushed correctly image

Running stencil init also receives the error. image

However, even though Stencil Init says it is adding the host, it is not saved in my config.stencil.json file unless I explicitely run stencil init -h https://api.bigcommerce.com image

Let me know if I can help with anything else. The biggest issue was not seeing changes reflected on localhost.

BC-AdamWard avatar Dec 22 '22 17:12 BC-AdamWard

Hi @BC-AdamWard, I don't see any errors, on the screenshots you provided. 'No Api host' message is just a warning to be aware of what is in your config

jairo-bc avatar Dec 28 '22 15:12 jairo-bc

I've had exactly the same issue as @BC-AdamWard. Am In the middle of doing a manual upgrade to Cornerstone 6.7 (from 1.3, don't ask), tried doing a test with a fresh install, get to the exact same point. Here's the error that it throws back:

not ok -- StoreSettingsLocaleError: Request failed with status code 403

URL: https://api.bigcommerce.com/stores/9x14icgu4u/v3/settings/store/locale Method: GET

Incidentally, tried using @BC-AdamWard's approach and firing stencil init -h https://api.bigcommerce.com/ but that would just throw back this error:

not ok -- Error: Could not fetch a list of the store channels: Request failed with status code 404

Been using Stencil/Cornerstone for my custom Bigcommerce page for a few years now, also the first time I've noticed this after I run stencil init:

Set API host to: https://api.bigcommerce.com/ You are now ready to go! To start developing, run $ stencil start

I've never seen it ask for the API host to be set, is that new, would that normally print out?

OloorinOfTheSouth avatar Dec 30 '22 13:12 OloorinOfTheSouth

Just to quickly update, I just tried running stencil start, just to see what would happen, haven't done anything or made any changes at all, haven't touched a single thing since the last post (given it's been NYE and all), and now Stencil miraculously starts up, but still with a No api host found warning injected in the first line. Screenshot 2023-01-01 at 2 23 01 am

So I can get past the API error for now it seems, but once I've booted Stencil up it looks like I have no dist folder generating. Great. I swear, just getting this environment up and running has been the biggest pain in the ass.

OloorinOfTheSouth avatar Jan 02 '23 06:01 OloorinOfTheSouth

I encountered this also, and was able to resolve it by recreating the API account. That is, as the site owner: Settings -> Api Accounts -> Create new Api Account Then create one using of type "Stencil CLI account".

Using the resulting values, rerun stencil init, e.g.: stencil init --url https://yourdomainy.com --token yourtoken

More info: I ran into this when trying to run stencil start locally on Windows 10. Our BigCommerce theme hadn't been updated for about a year.

LoveSpirals avatar Jan 14 '23 03:01 LoveSpirals

Hello, have you solved this problem? I also had this problem and recreated the token, which was also not resolved.

JinMengmeng1998 avatar Feb 02 '23 02:02 JinMengmeng1998

Hello, have you solved this problem? I also had this problem and recreated the token, which was also not resolved.

Yes, I recreated the API account and then re-ran stencil init. That's all I know. :|

LoveSpirals avatar Feb 02 '23 03:02 LoveSpirals

  • But I recreated the token and it didn't work.(crying)

JinMengmeng1998 avatar Feb 02 '23 03:02 JinMengmeng1998

This is what I had to do. I think there's a scope issue with Stencil CLI tokens. When you're creating a new token, create a V2/V3 API token with the following scopes set:

  • Information & settings: modify
  • Themes: modify
  • Sites & routes: read-only

GearUp2Go avatar Feb 02 '23 03:02 GearUp2Go

I was able to resolve the "No Api host" issue with the following command stencil init -h https://api.bigcommerce.com it added "apiHost": "https://api.bigcommerce.com" to the config.stencil.json

{
  "customLayouts": {
    "brand": {},
    "category": {},
    "page": {},
    "product": {}
  },
  "normalStoreUrl": "https://[YOUR_STORE_URL].mybigcommerce.com/",
  "port": 3000,
  "apiHost": "https://api.bigcommerce.com"
}

n3k027 avatar Jan 08 '24 22:01 n3k027