Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin): Add a note about JavaScript modules to Nextcloud 28 upgrade guides #11471

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 26, 2024

☑️ Resolves

🖼️ Screenshots

image

@susnux
Copy link
Contributor Author

susnux commented Jan 26, 2024

/backport to stable28

@MichaIng
Copy link
Member

MichaIng commented Jan 26, 2024

At least on Debian, the MIME type is added automatically for all webservers, with their own configs or /etc/mime.types, so this part is probably less important. However, in which case and which absolute directory are you expecting conf/mime.types? Like this, me, and hence I guess many others, won't be able to know what to do, if the correct MIME type is really not served anyway. Not sure whether /etc/mime.types is used across all (relevant) distros and webservers, but this is probably a more clear config to look at? For Apache otherwise /etc/apache2/mods-available/mime.conf, or of course any other server/vhost config.

Just checked back: Nginx uses /etc/nginx/mime.types, Apache and Lighttpd use /etc/mime.types.

What I was actually missing in the docs was not the MIME type (still good to mention it), but the rewrites: The default/example webserver configs rewrite everything to index.php, which is not explicitly excluded from the rewrite, via RewriteCond in Apache, and location ~ \.(?:...|mjs|...) { block in Nginx.

Another thing is the Cache-Control header. So basically 3 things:

  1. Assure that requests to .mjs are not rewritten to index.php but served directly.
  2. Assure that .mjs files are served with text/javascript MIME type.
  3. Serve .mjs files with Cache-Control "max-age=15778463" header, like other static assets, respectively Cache-Control "max-age=15778463, immutable" for those with v= query parameter.

All of this can be usually achieved by adding mjs to the list(s) of asset file extensions in the existing Nextcloud webserver config.

Copy link
Contributor

github-actions bot commented May 2, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

@st3iny
Copy link
Member

st3iny commented Jun 18, 2024

@MichaIng Nice summary. Do we need to do anything else here or is this PR sufficient?

@MichaIng
Copy link
Member

@st3iny
None of the points I listed are addressed in this PR yet 😉. Let me do a concrete suggestion.

Comment on lines +15 to +17
* As some core app now make use of JavaScript modules, make sure your web server is serving ``.mjs`` files with JavaScript MIME type.
When using Apache with ``.htaccess`` configuration this will be done automatically, if your Apache is not configured to use the ``.htaccess`` files make sure ``.mjs`` is added as a file extension for JavaScript in ``conf/mime.types``.
For NGinx please refer to the our recommended :ref:`nginx configuration<nginx-config>`.
Copy link
Member

@MichaIng MichaIng Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* As some core app now make use of JavaScript modules, make sure your web server is serving ``.mjs`` files with JavaScript MIME type.
When using Apache with ``.htaccess`` configuration this will be done automatically, if your Apache is not configured to use the ``.htaccess`` files make sure ``.mjs`` is added as a file extension for JavaScript in ``conf/mime.types``.
For NGinx please refer to the our recommended :ref:`nginx configuration<nginx-config>`.
* As some core app now make use of JavaScript modules, make sure your web server is not rewriting requests to ``.mjs`` files, but serves them with `text/javascript` MIME type and proper `Cache-Control` header, like ``.js`` and other static file extensions.
* When using Apache with ``.htaccess`` configuration, this will be done automatically.
* For Nginx, please refer to the our recommended :ref:`Nginx configuration<nginx-config>`.
* For other setups, make sure to add ``.mjs`` to the list of static file extensions in web server configs and in case define its MIME type in `/etc/mime.types`.
  • I hope nested lists work like that.
  • The last point is moreless taken from the above point about .ogg and .flac files. Most web server configs have one or more blocks with a list of all static file extensions Nextcloud makes use of. Adding .mjs there to be handled like .js and others, should be sufficient in most cases. The MIME type might be the only exception on older distros, where default /etc/mime.types or related default web server configs do not contain .mjs yet.

@kesselb kesselb merged commit 75d3a0c into master Jun 18, 2024
11 checks passed
@kesselb kesselb deleted the fix/mjs-upgrade branch June 18, 2024 16:06
@kesselb
Copy link
Contributor

kesselb commented Jun 18, 2024

/backport to stable29

@kesselb
Copy link
Contributor

kesselb commented Jun 18, 2024

I merged the pr to finally get it in.

@MichaIng would you mind shooting a follow-up with your suggestions?

MichaIng added a commit that referenced this pull request Jun 18, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
@MichaIng
Copy link
Member

@kesselb
Done: #11912

MichaIng added a commit that referenced this pull request Jun 18, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit that referenced this pull request Jun 18, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit that referenced this pull request Jun 18, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
MichaIng added a commit that referenced this pull request Jun 18, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
backportbot bot pushed a commit that referenced this pull request Jun 25, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
backportbot bot pushed a commit that referenced this pull request Jun 25, 2024
To cover rewrites, Cache-Control header, and give a concrete config file for MIME types, as suggested here: #11471 (comment)

Signed-off-by: MichaIng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mjs to upgrade guide for admins
4 participants