in frontend

Hi, I’m a complete rookie to cockpit, and a relative rookie to web dev using APIs and things, so I apologise in advance for maybe a dumb question.

I have set in my config.yml my, and I was wondering how in my frontend I can get that value to render it?

I’m working with express, and handlebars to learn all these technologies work. Thanks in advance!

I don’t think, there is an api endpoint available. Just built your own.

Create a file appname.php with this content:

return $this[''];

Copy it into path/to/cockpit/config/api/appname.php. Now you can call it via /api/appname?token=xxtokenxx.

Or for public access copy it into path/to/cockpit/config/api/public/appname.php. Now you can call it without an api key via /api/public/appname.

Thanks @raffaelj for the help. Nice to know I can make my own endpoints.

Instead of having your own endpoint, why not create a singleton (e.g. site settings), that aggregates all site-wide settings (e.g. site name, site slogan, seo tags, etc…). The doesnt need necessary to be the same in the backend and frontend.

1 Like

On that’s a nice idea. Thanks for the suggestion.