dshoreman / servidor

A modern web application for managing servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Undefined` or `null` showing in document root when primary domain isn't set

dshoreman opened this issue · comments

If you create a new site and change the Project type before setting the primary domain, the document root will show as /var/www/undefined (see screenshot below).

The fix is probably as simple as setting a default value of '' for the primary domain in the Site vueX module — I don't believe it's currently set at all.

There is also a similar issue where, if you load an existing "new" site that hasn't had its primary domain configured, it will show null in place of undefined in the document root. Again this is probably just a case of setting a default empty value in the store.


Hey, I'd like to give this a go :)

All yours!

Hey there, I've played around with it a while and I've come to the conclusion that it is not as simple as setting the primary domain in the Site state. This is due to the fact that if this property is set to empty string, then when /api/sites is posted to, a 422 exception is thrown with the error message: The primary_domain is not a valid FQDN.

I think this makes sense, it should always be undefined or a valid domain name, not an empty string at anytime.

Due to this, I've instead implemented a solution that checks if primary domain is defined and is not, it replaces it with empty string when setting the document root attribute.

Only thing is it looks a little strange when project type is Laravel and document root is /var/www//public. Not really sure what to do instead in that situation though...

What do you think? :)

Thanks @Mouzourides, good thinking on the validation errors... That's probably the reason the optional fields were all left undefined in the first place.

We could update the last line to site.document_root = site.primary_domain ? var : ''; instead of the (... || '') where we set val initially, but to be honest I'm not too worried about it looking odd for Laravel projects. Just fixing the undefined/null output is good enough for now.

The whole form will probably need to be redesigned at some point anyway, especially when it supports non-web projects. Those won't even have a domain and the doc root will probably just be the home directory.

ezoic increase your site revenue