Yes, You're right. This is a server-side thing and I have done this by adding these 4 lines of code inside htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
Edit: this goes for https NO-www