[SOLVED] All extra apps fails to load due to MIME type mismatch

Nextcloud version:12.0.2
Operating system and version: Arch Linux
nginx-mainline version: 1.13.4
PHP version: 7.1.9
Is this the first time you’ve seen this error?: No, it happens on two of my instances, first time I’m reporting it in this firum

Can you reliably replicate it?: Yup, wrong on 2 servers

The issue you are facing: Apps won’t load because of a mime type error

Refused to execute script from ‘https://sc1.c0rn3j.com/wapps/weather/js/app.js?v=c9c946f4245a864f60a240c6d8cd869a-0’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

The output of your Apache/nginx/system log in /var/log/____:


Here are my nginx config files, this behavior happens on both of them.

I have installed NC by adding these lines to config.php


‘apps_paths’ =>
array (
0 =>
array (
‘path’ => ‘/usr/share/webapps/nextcloud/apps’,
‘url’ => ‘/apps’,
‘writable’ => false,
),
1 =>
array (
‘path’ => ‘/var/www/nextcloud/apps’,
‘url’ => ‘/wapps’,
‘writable’ => true,
),
),


and afterwards executing these commands.

sudo mkdir -p /var/www/nextcloud/apps
sudo chown http:http -R /var/www/nextcloud

sudo mkdir -p /usr/share/webapps/nextcloud/data
sudo chown root:http /usr/share/webapps/nextcloud/data
sudo chmod 770 /usr/share/webapps/nextcloud/data

This seems to happen because of the path for the second apps folder. I can replicate the issue but it vanishes if I use

‘path’ => ‘/usr/share/webapps/nextcloud/apps2’,
‘url’ => ‘/apps2’,

Not sure yet if it should happen though or why it happens. I thought nginx wasn’t serving even files like this directly and instead they get sent through the routes and php-fpm. Adding a location block with an alias to nginx might work but I didn’t get around to testing that yet either.

1 Like

I have moved the second apps folder to apps2 too like in your example, moved the already installed apps and everything started working.

So the issue is having the apps folder outside of the /usr/share/webapps/nextcloud/ folder.

I’m not sure how exactly I’d add an alias block with nginx, but thanks a lot for moving me closer to a proper solution!

location ~ /wapps/(.*)$ {
alias /var/www/nextcloud/apps/$1;
}

This block needs to be added to the nginx config(with appropriate path ofc) if you are placing the apps folder anywhere outside the root folder of nextcloud.