Error: Missing required config value at 'app.baseUrl' after fresh npx @backstage/create-app and plugin-create
See original GitHub issueHello!
Followed docs to create fresh instance of backstage and to create fresh plugin. According to docs, I can start plugin in isolation.
Expected Behavior
Plugin start in Isolation and I can enjoy hot reload and fast iteration time
Current Behavior
Error: Missing required config value at ‘app.baseUrl’ after yarn start
Possible Solution
I tried placing app-config.yaml in plugin directory, tried using env var APP_CONFIG_app_baseUrl - still getting this error. May be it is suggested behavior, cause I managed to run it in backstage/backstage cloned repo. If so, It would be nice to have a note in docs about it.
Steps to Reproduce
npx @backstage/create-app
yarn create-plugin
cd plugins/...
yarn start
Context
Backstage is pretty complex environment for a newcomer, I enjoy exploring it in my way, and my way is start to build something fast. So hot reloading is pretty crucial. I could use main repo, but it’s too heavy and hardware intensive :<
Your Environment
- NodeJS Version (v12):LTS 14
- Operating System and Version (e.g. Ubuntu 14.04):Ubuntu 20.04 LTS
- Browser Information: Chrome
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Thanks for reporting @dimkk - I was able to reproduce the error. I believe one should be able to start a standalone plugin even on a newly created Backstage app.
TL;DR of problem
I did some debugging to find out why this is happening. The
app-config.yaml
file is loaded correctly, but Backstage apps need aconfig.d.ts
to set the visibility of its configs likeapp.baseUrl
tofrontend
. Read more about visibility of configs here. By default, no configs are visible to thefrontend
level. This is already being done in the backstage/backstage mono-repo, which is why you didn’t encounter this problem.Quick fix
@dimkk Quick fix to unblock yourself is to add a
config.d.ts
file inplugins/<newly-created-plugin>
.This increases the visibility of
app.baseUrl
to the frontend. And then update the relevantpackage.json
of the plugin to load the config file. Also set the file asconfigSchema
. You can read more here. This should solve the issue! (It did for me!)Details
The backstage-cli plugin:serve command loads all the app config files and tries to serve the bundle for the plugin. If we inspect the loaded config at this point, it looks like this
Note that the
frontendConfig.data
is empty since there is no config schema file likeconfig.d.ts
so far in the new Backstage app, hence all the configs are by default set to be visible tobackend
only.Later on, the serve bundle logic is unable to get the URL where to serve the bundle at. https://github.com/backstage/backstage/blob/81a6c95b0ab08df35da72b3e518630cdcabafdcc/packages/cli/src/lib/bundler/config.ts#L95
Proposed fix
The skeleton used by
npx @backstage/create-app
should have a simpleconfig.d.ts
file inpackages/app
which sets the visibility ofapp.baseUrl
to frontend.BUT, I noticed that our config-loader package DOES NOT look for
config.d.ts
files insidepackages/app
andpackages/backend
. This makes it harder to achieve the above. I think this is probably not intentional, and should be fixed. But @Rugvip would know more!cc @backstage/reviewers
Actually worked! Thanks!