App.name in frontend


#1

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 app.name, 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!


#2

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

Create a file appname.php with this content:

<?php
return $this['app.name'];

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.


#3

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


#4

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 App.name doesnt need necessary to be the same in the backend and frontend.


#5

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