server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: v28 - Your webserver does not serve `.mjs` files using the JavaScript MIME type...

Open rchaconmolero opened this issue 1 year ago • 46 comments

⚠️ This issue respects the following points: ⚠️

Bug description

After upgrade from 28.0.1 to 28.0.2 RC1 appears in security and setup warning page: There are some errors regarding your setup. Your webserver does not serve .mjs files using the JavaScript MIME type. This will break some apps by preventing browsers from executing the JavaScript files. You should configure your webserver to serve .mjs files with either the text/javascript or application/javascript MIME type.

Steps to reproduce

  1. Upgrade vie Web GUI.
  2. No error in upgrade process.
  3. There are some errors regarding your setup. Your webserver does not serve .mjs files using the JavaScript MIME type. This will break some apps by preventing browsers from executing the JavaScript files. You should configure your webserver to serve .mjs files with either the text/javascript or application/javascript MIME type.

Expected behavior

No messages about "Your webserver does not serve .mjs files using the JavaScript MIME type."

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

None

Is this bug present after an update or on a fresh install?

Updated from a MINOR version (ex. 22.1 to 22.2)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • [X] Default user-backend (database)
  • [X] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Configuration report

# sudo -u www-data php /var/www/nextcloud/occ config:list system
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "next01d.canal-sur.interno"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.2.0",
        "overwrite.cli.url": "https:\/\/next01d.canal-sur.interno\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "filelocking.enabled": "true",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "dbindex": 0,
            "password": "***REMOVED SENSITIVE VALUE***",
            "timeout": 1.5
        },
        "default_phone_region": "ES",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpauthtype": "LOGIN",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpdebug": true,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpstreamoptions": {
            "ssl": {
                "verify_peer": false,
                "verify_peer_name": false
            }
        },
        "htaccess.RewriteBase": "\/",
        "updater.release.channel": "beta",
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "app_install_overwrite": [
            "twofactor_admin"
        ],
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "logtimezone": "Europe\/Madrid",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "logfile_audit": "\/var\/log\/nextcloud\/nextcloud.log",
        "trashbin_retention_obligation": "auto, 7",
        "versions_retention_obligation": "auto, 7",
        "allow_user_to_change_display_name": false,
        "activity_expire_days": 1,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "ldapUserCleanupInterval": 30,
        "session_lifetime": 86400,
        "remember_login_cookie_lifetime": "0",
        "session_keepalive": "false",
        "preview_max_x": 1024,
        "preview_max_y": 768,
        "preview_max_scale_factor": 1,
        "updater.secret": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 17
    }
}

List of activated Apps

# sudo -u www-data php /var/www/nextcloud/occ app:list
Enabled:
  - activity: 2.20.0
  - admin_audit: 1.18.0
  - bruteforcesettings: 2.8.0
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - contacts: 5.5.1
  - contactsinteraction: 1.9.0
  - dashboard: 7.8.0
  - dav: 1.29.1
  - federatedfilesharing: 1.18.0
  - federation: 1.18.0
  - files: 2.0.0
  - files_accesscontrol: 1.18.0
  - files_automatedtagging: 1.18.0
  - files_external: 1.20.0
  - files_pdfviewer: 2.9.0
  - files_reminders: 1.1.0
  - files_sharing: 1.20.0
  - files_trashbin: 1.18.0
  - files_versions: 1.21.0
  - groupfolders: 16.0.3
  - impersonate: 1.15.0
  - logreader: 2.13.0
  - lookup_server_connector: 1.16.0
  - nextcloud_announcements: 1.17.0
  - notifications: 2.16.0
  - oauth2: 1.16.3
  - onlyoffice: 9.0.0
  - password_policy: 1.18.0
  - photos: 2.4.0
  - privacy: 1.12.0
  - provisioning_api: 1.18.0
  - recommendations: 2.0.0
  - related_resources: 1.3.0
  - serverinfo: 1.18.0
  - settings: 1.10.1
  - sharebymail: 1.18.0
  - support: 1.11.0
  - survey_client: 1.16.0
  - systemtags: 1.18.0
  - text: 3.9.1
  - theming: 2.3.0
  - twofactor_backupcodes: 1.17.0
  - updatenotification: 1.18.0
  - user_ldap: 1.19.0
  - user_status: 1.8.1
  - viewer: 2.2.0
  - workflowengine: 2.10.0
Disabled:
  - encryption: 2.16.0
  - files_retention: 1.16.0 (installed 1.16.0)
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - firstrunwizard: 2.17.0 (installed 2.16.0)
  - suspicious_login: 6.0.0
  - twofactor_totp: 10.0.0-beta.2 (installed 8.0.0-alpha.0)
  - weather_status: 1.8.0 (installed 1.6.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No response

Additional info

No response

rchaconmolero avatar Jan 20 '24 18:01 rchaconmolero

Are you saying you know with certainty the test should pass in your environment?

Can you confirm things that require mjs are fully functioning:

  • Does the Activity page function?
  • Does Administration settings->Logging show current log entries?

joshtrichards avatar Jan 20 '24 19:01 joshtrichards

Yes. Activity and logging show current logs entries.

log Activity

rchaconmolero avatar Jan 20 '24 19:01 rchaconmolero

What is the output of:

curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs

solracsf avatar Jan 20 '24 20:01 solracsf

@rchaconmolero this would be interesting because what that test does is testing to access your instance and check the returned mime type. Meaning if your server can not resolve its own host name it will fail here.

What is the output of:

curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs

Also it would be really helpful if you could set the logging level to debug and send the logfile or at least search the log for an entry like the following and send that entry if it exists:

Can not connect to local server for checking JavaScript modules support

susnux avatar Jan 21 '24 00:01 susnux

Meaning if your server can not resolve its own host name it will fail here.

Specifically*: At least one of Nextcloud's configured trusted_domains must be accessible (via its URL) from the Nextcloud app server itself.

*Or at least that's my take from my first read though of this recently added code

joshtrichards avatar Jan 21 '24 04:01 joshtrichards

In Chrome or webserver, URL --> "https://next01d.canal-sur.interno/apps/settings/js/esm-test.mjs"

/**

  • This is a dummy file for testing webserver support of JavaScript modules. */

export default 'Hello'

.- The output to the command

# curl -I https://next01d.canal-sur.interno/apps/settings/js/esm-test.mjs HTTP/2 200
strict-transport-security: max-age=15552000; includeSubDomains
referrer-policy: no-referrer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-robots-tag: noindex, nofollow
x-xss-protection: 1; mode=block
last-modified: Sat, 20 Jan 2024 10:43:51 GMT
etag: "6d-60f5e45bc0776"
accept-ranges: bytes
content-length: 109
vary: Accept-Encoding
cache-control: max-age=15778463
content-type: text/javascript
date: Sun, 21 Jan 2024 05:27:03 GMT
server: Apache

rchaconmolero avatar Jan 21 '24 04:01 rchaconmolero

I can confirm the same issue, after update: 28.0.1 to 28.0.2 RC1

My output from curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs :

HTTP/1.1 200 OK
Date: Sun, 21 Jan 2024 11:11:18 GMT
Server: Apache/2.4.57 (AlmaLinux) OpenSSL/3.0.7
Strict-Transport-Security: max-age=63072000
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: noindex, nofollow
X-XSS-Protection: 1; mode=block
Upgrade: h2
Connection: Upgrade
Last-Modified: Sun, 21 Jan 2024 07:11:10 GMT
ETag: "6d-60f6f6af88f68"
Accept-Ranges: bytes
Content-Length: 109
Cache-Control: max-age=15778463
Content-Type: text/javascript

pandusen avatar Jan 21 '24 11:01 pandusen

For those with the problem, can you please:

Also it would be really helpful if you could set the logging level to debug and send the logfile here, or at least, search the log for an entry like the following and send that complete entry if it exists:

Can not connect to local server for checking JavaScript modules support

solracsf avatar Jan 21 '24 13:01 solracsf

I am simultaneously also have the "Could not load log entries" error. Currently investigating. Edit: Above was a ublock issue.

Yes, my log contains this entry:

LocalServerExceptionCould not detect any host Can not connect to local server for checking JavaScript modules support

Also has this Entry: LocalServerException Host violates local access rules Can not connect to local server for checking JavaScript modules support

pandusen avatar Jan 21 '24 13:01 pandusen

@pandusen can you post the full RAW stack trace from the log reader app about Can not connect to local server for checking JavaScript modules support?

image

solracsf avatar Jan 21 '24 13:01 solracsf

Sure (I have replaced fqdn and username.)

Could not detect any host:

{
  "reqId": "Za0hieI4tzKF-QVLu1D6wwAA1iE",
  "level": 0,
  "time": "2024-01-21T13:52:11+00:00",
  "remoteAddr": "192.168.0.30",
  "user": "user",
  "app": "settings",
  "method": "GET",
  "url": "/index.php/settings/ajax/checksetup",
  "message": "Can not connect to local server for checking JavaScript modules support",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
  "version": "28.0.2.0",
  "exception": {
    "Exception": "OCP\\Http\\Client\\LocalServerException",
    "Message": "Could not detect any host",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/nextcloud/lib/private/Http/Client/Client.php",
        "line": 260,
        "function": "preventLocalAddress",
        "class": "OC\\Http\\Client\\Client",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/apps/settings/lib/SetupChecks/JavaScriptModules.php",
        "line": 67,
        "function": "head",
        "class": "OC\\Http\\Client\\Client",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/SetupCheck/SetupCheckManager.php",
        "line": 49,
        "function": "run",
        "class": "OCA\\Settings\\SetupChecks\\JavaScriptModules",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/apps/settings/lib/Controller/CheckSetupController.php",
        "line": 303,
        "function": "runAll",
        "class": "OC\\SetupCheck\\SetupCheckManager",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "check",
        "class": "OCA\\Settings\\Controller\\CheckSetupController",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/html/nextcloud/lib/base.php",
        "line": 1069,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/index.php",
        "line": 39,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/html/nextcloud/lib/private/Http/Client/Client.php",
    "Line": 192,
    "message": "Can not connect to local server for checking JavaScript modules support",
    "exception": [],
    "url": "cloud.nextcloud.tld/apps/settings/js/esm-test.mjs",
    "CustomMessage": "Can not connect to local server for checking JavaScript modules support"
  },
  "id": "65ad22baddbdd"
}

Host violates local access rules:

{
  "reqId": "Za0hieI4tzKF-QVLu1D6wwAA1iE",
  "level": 0,
  "time": "2024-01-21T13:52:11+00:00",
  "remoteAddr": "192.168.0.30",
  "user": "user",
  "app": "settings",
  "method": "GET",
  "url": "/index.php/settings/ajax/checksetup",
  "message": "Can not connect to local server for checking JavaScript modules support",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
  "version": "28.0.2.0",
  "exception": {
    "Exception": "OCP\\Http\\Client\\LocalServerException",
    "Message": "Host violates local access rules",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php",
        "line": 35,
        "function": "OC\\Http\\Client\\{closure}",
        "class": "OC\\Http\\Client\\DnsPinMiddleware",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php",
        "line": 31,
        "function": "__invoke",
        "class": "GuzzleHttp\\PrepareBodyMiddleware",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/RedirectMiddleware.php",
        "line": 71,
        "function": "GuzzleHttp\\{closure}",
        "class": "GuzzleHttp\\Middleware",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php",
        "line": 63,
        "function": "__invoke",
        "class": "GuzzleHttp\\RedirectMiddleware",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/HandlerStack.php",
        "line": 75,
        "function": "GuzzleHttp\\{closure}",
        "class": "GuzzleHttp\\Middleware",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php",
        "line": 331,
        "function": "__invoke",
        "class": "GuzzleHttp\\HandlerStack",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php",
        "line": 168,
        "function": "transfer",
        "class": "GuzzleHttp\\Client",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php",
        "line": 187,
        "function": "requestAsync",
        "class": "GuzzleHttp\\Client",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Http/Client/Client.php",
        "line": 261,
        "function": "request",
        "class": "GuzzleHttp\\Client",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/apps/settings/lib/SetupChecks/JavaScriptModules.php",
        "line": 67,
        "function": "head",
        "class": "OC\\Http\\Client\\Client",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/SetupCheck/SetupCheckManager.php",
        "line": 49,
        "function": "run",
        "class": "OCA\\Settings\\SetupChecks\\JavaScriptModules",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/apps/settings/lib/Controller/CheckSetupController.php",
        "line": 303,
        "function": "runAll",
        "class": "OC\\SetupCheck\\SetupCheckManager",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "check",
        "class": "OCA\\Settings\\Controller\\CheckSetupController",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/html/nextcloud/lib/base.php",
        "line": 1069,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/index.php",
        "line": 39,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/html/nextcloud/lib/private/Http/Client/DnsPinMiddleware.php",
    "Line": 150,
    "message": "Can not connect to local server for checking JavaScript modules support",
    "exception": [],
    "url": "https://cloud.nextcloud.tld/apps/settings/js/esm-test.mjs",
    "CustomMessage": "Can not connect to local server for checking JavaScript modules support"
  },
  "id": "65ad22badfee9"
}

pandusen avatar Jan 21 '24 14:01 pandusen

{"reqId":"gyjwFmfci2qcrrnrMlA6","level":0,"time":"2024-01-21T15:24:40+01:00","remoteAddr":"10.236.138.4","user":"adminnext","app":"settings","method":"GET","url":"/settings/ajax/checksetup","message":"Can not connect to local server for checking JavaScript modules support","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0","version":"28.0.2.0","exception":{"Exception":"OCP\Http\Client\LocalServerException","Message":"Could not detect any host","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Http/Client/Client.php","line":260,"function":"preventLocalAddress","class":"OC\Http\Client\Client","type":"->"},{"file":"/var/www/nextcloud/apps/settings/lib/SetupChecks/JavaScriptModules.php","line":67,"function":"head","class":"OC\Http\Client\Client","type":"->"},{"file":"/var/www/nextcloud/lib/private/SetupCheck/SetupCheckManager.php","line":49,"function":"run","class":"OCA\Settings\SetupChecks\JavaScriptModules","type":"->"},{"file":"/var/www/nextcloud/apps/settings/lib/Controller/CheckSetupController.php","line":303,"function":"runAll","class":"OC\SetupCheck\SetupCheckManager","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"check","class":"OCA\Settings\Controller\CheckSetupController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\AppFramework\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1069,"function":"match","class":"OC\Route\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":39,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/Http/Client/Client.php","Line":192,"message":"Can not connect to local server for checking JavaScript modules support","exception":[],"url":"next01d.canal-sur.interno/apps/settings/js/esm-test.mjs","CustomMessage":"Can not connect to local server for checking JavaScript modules support"},"id":"65ad296c9a981"}

rchaconmolero avatar Jan 21 '24 14:01 rchaconmolero

@susnux should we add a

'nextcloud' => ['allow_local_address' => true]

to the httpClient params?

https://github.com/nextcloud/server/blob/1612d025cf21ac0ae70327c46dd59be66c096627/apps/settings/lib/SetupChecks/JavaScriptModules.php#L67

solracsf avatar Jan 21 '24 16:01 solracsf

@susnux should we add a

'nextcloud' => ['allow_local_address' => true]

to the httpClient params?

https://github.com/nextcloud/server/blob/1612d025cf21ac0ae70327c46dd59be66c096627/apps/settings/lib/SetupChecks/JavaScriptModules.php#L67

Yes! I wonder why it did work when I tested it. This will probably resolve this issue!

susnux avatar Jan 21 '24 18:01 susnux

@pandusen please try https://github.com/nextcloud/server/pull/42999 and report back if possible.

solracsf avatar Jan 21 '24 22:01 solracsf

In my case, with 'allow_local_address' => true, in config.php does not resolve the problem.

rchaconmolero avatar Jan 22 '24 09:01 rchaconmolero

Same here. The output of curl shows it being returned as content-type: text/javascript , however I still get the error show. Adding allow_local_address to the config.php does not change anything.

scttstrck avatar Jan 22 '24 09:01 scttstrck

Have you all tried the PR, or just edited the config.php file?

solracsf avatar Jan 22 '24 11:01 solracsf

I did both. I edited line 67 in apps/settings/lib/SetupChecks/JavaScriptModules.php , which was then formatted into multiple lines, and I added line 78.

scttstrck avatar Jan 22 '24 12:01 scttstrck

I did both. I edited line 67 in apps/settings/lib/SetupChecks/JavaScriptModules.php , which was then formatted into multiple lines, and I added line 78.

Can you please look at your log and send the log message?

Also it would be really helpful if you could set the logging level to debug and send the logfile here, or at least, search the log for an entry like the following and send that complete entry if it exists:

Can not connect to local server for checking JavaScript modules support

As this should now be a different one

susnux avatar Jan 22 '24 14:01 susnux

Ok I'm out of ideas here, and I can't reproduce the error on my test instances 😭

curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs

But, as long as the Content-Type returned by the above comand is either application/javascript or text/javascript, this warning/error is purely cosmetic and everything works as expected 👍

solracsf avatar Jan 22 '24 14:01 solracsf

The PR by it selv, cleared the error in the Nextcloud dashboard. Adding the line in config.php, makes no difference. For good measure i copied the edited loop from my JavaScriptModeules.php, in case i mistyped, and just broke the checking function.

foreach ($testURLs as $testURL) {
			try {
				$client = $this->clientService->newClient();
				$response = $client->head($testURL, [
					'connect_timeout' => 10,
					'nextcloud' => [
						'allow_local_address' => true,
					],
				]);
				if (preg_match('/(text|application)\/javascript/i', $response->getHeader('Content-Type'))) {
					return SetupResult::success();
				}
			} catch (\Throwable $e) {
				$this->logger->debug('Can not connect to local server for checking JavaScript modules support', ['exception' => $e, 'url' => $testURL]);
				return SetupResult::warning($this->l10n->t('Could not check for JavaScript support. Please check manually if your webserver serves `.mjs` files using the JavaScript MIME type.'));
			}
		}
		return SetupResult::error($this->l10n->t('Blablabla'));

pandusen avatar Jan 22 '24 16:01 pandusen

@pandusen so I understand it correctly, if using the code from the pull request the error is gone?

susnux avatar Jan 22 '24 16:01 susnux

@susnux Yes, in my instance, the error is gone after updating the code. It is neither in Dashboard or Logfile at Debug level. (Seemingly, I dont even have to add anything to the Nextcloud config.php)

pandusen avatar Jan 22 '24 17:01 pandusen

ok thank you :)

susnux avatar Jan 22 '24 19:01 susnux

After upgrading to 28.02 RC3 I noticed that there is no support for self-signed certificates and the behavior is to leave an unclear-able warning message:

"Could not check for JavaScript support. Please check manually if your webserver serves .mjs files using the JavaScript MIME type."

Can you add a flag in the JavaScriptModeules.php to support self-signed certificates? Something like: 'nextcloud' => 'allow_local_address' => true, 'ignore_ssl_certificate' => true, ],

OR

'nextcloud' => 'allow_local_address' => true, 'allow_self_signed_certs' => true, ],

theoriginalguy avatar Jan 26 '24 16:01 theoriginalguy

After upgrading to 28.02 RC3 I noticed that there is no support for self-signed certificates and the behavior is to leave an unclear-able warning message:

"Could not check for JavaScript support. Please check manually if your webserver serves .mjs files using the JavaScript MIME type."

Can you add a flag in the JavaScriptModeules.php to support self-signed certificates? Something like: 'nextcloud' => 'allow_local_address' => true, 'ignore_ssl_certificate' => true, ],

OR

'nextcloud' => 'allow_local_address' => true, 'allow_self_signed_certs' => true, ],

@theoriginalguy I think this is a good solution. In RC4 version the problem still occurs

WechuTM avatar Jan 27 '24 16:01 WechuTM

After upgrading to 28.02 RC3 I noticed that there is no support for self-signed certificates and the behavior is to leave an unclear-able warning message:

Different issue, handled in https://github.com/nextcloud/server/issues/43153

susnux avatar Jan 28 '24 14:01 susnux

For those that experience this issue and use nginx as reverse proxy:

I had the same issue and tested with esm-test.mjs command above:

$ curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs
HTTP/2 200 
server: nginx
date: Thu, 01 Feb 2024 14:19:31 GMT
content-type: application/octet-stream
content-length: 109
last-modified: Thu, 01 Feb 2024 08:37:38 GMT
etag: "65bb5852-6d"
strict-transport-security: max-age=63072000; includeSubDomains;  preload
referrer-policy: no-referrer
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-robots-tag: noindex, nofollow
x-xss-protection: 1; mode=block
accept-ranges: bytes

Noting that the content-type is application/octet-stream being my default mime-type for extensions, nginx obviously doesn't have the '.mjs' extension in the mime.types file.

I fixed the issue by adding the .mjs extension to nginx.conf like this:

http {
	...
	
	include /etc/nginx/mime.types;

	types {
	    application/javascript mjs;
	}

	default_type application/octet-stream;
	
	...
}

Credits: https://github.com/storybookjs/storybook/issues/20157#issuecomment-1500456820

peternormann avatar Feb 01 '24 14:02 peternormann

For those that experience this issue and use nginx as reverse proxy:

I had the same issue and tested with esm-test.mjs command above:

$ curl -I https://your.nextcloud.tld/apps/settings/js/esm-test.mjs
HTTP/2 200 
server: nginx
date: Thu, 01 Feb 2024 14:19:31 GMT
content-type: application/octet-stream
content-length: 109
last-modified: Thu, 01 Feb 2024 08:37:38 GMT
etag: "65bb5852-6d"
strict-transport-security: max-age=63072000; includeSubDomains;  preload
referrer-policy: no-referrer
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-robots-tag: noindex, nofollow
x-xss-protection: 1; mode=block
accept-ranges: bytes

Noting that the content-type is application/octet-stream being my default mime-type for extensions, nginx obviously doesn't have the '.mjs' extension in the mime.types file.

I fixed the issue by adding the .mjs extension to nginx.conf like this:

http {
	...
	
	include /etc/nginx/mime.types;

	types {
	    application/javascript mjs;
	}

	default_type application/octet-stream;
	
	...
}

Credits: storybookjs/storybook#20157 (comment)

After fixing the mime-type issue as described above, my nginx still won't deliver .mjs correctly.

In the /etc/nginx/sites-enabled/your-vhost.conf I had to add mjs also: Look for this and add mjs to location:

# Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|mjs|js|woff2?|svg|gif|map|png|jpg|ico)$ {

cpu2910 avatar Feb 01 '24 18:02 cpu2910