Articles not opening in browser

Hi @rcgillis

We recently upgraded our journal platform to OJS 3.5 (xlescience.org). However, we are encountering an issue where uploaded articles are not opening directly in the browser. Instead, they can only be downloaded.

Based on the suggestions in the PKP forum, I attempted the following steps:

  • Added the appropriate MIME types

  • Updated the .htaccess file

Unfortunately, these changes did not resolve the issue. We also contacted our hosting provider, and they confirmed that the server configuration seems fine. Their reply is provided below for your reference:

Could you please advise on how to resolve this issue? We would greatly appreciate any guidance or troubleshooting steps to ensure that articles open directly in the browser as expected.

Thank you for your support.

Hi @srinivasanchelliah,

I pulled your post into a separate post as it might be a different issue than that which described on the other forum post you posted under. Are you (or your hosting team) able to access your PHP error logs and report on errors found there? Often times there are clues that are found in those log messages that can help to pinpoint what might be causing these type of issues.

-Roger
PKP Team

Hi @rcgillis

Thanks for moving this into a separate post. I checked my PHP error logs and noticed that no PHP errors are being reported.

Here’s my current PHP.ini configuration:

log_errors = On
error_log = /home/xlescien/public_html/errorlog.txt

However, I haven’t seen any errorlog.txt file created on the server.

We would greatly appreciate any guidance or troubleshooting steps to ensure that articles open directly in the browser as expected

Thank you

Hi @srinivasanchelliah,

Thanks for following up on these additional details. I’m not entirely sure what might be causing this, but I will flag it for our team to have a look at when they are avaialble.

Best regards,

Roger
PKP Team

Hi @rcgillis

Thank you for your follow-up and for escalating this to your team.

I appreciate the support, and I’ll wait to hear back once they’ve had a chance to review.

Thank you in advance

With Regards

C. Srinivasan

Hi @srinivasanchelliah,

This is the same issue described in this thread:

The solution is to configure your webserver to serve .mjs files with the appropriate MIME type (text/javascript). This is typically done through CPanel. See for example:

https://docs.cpanel.net/cpanel/advanced/mime-types/

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher

We have already reviewed the referenced thread and configured the necessary MIME settings in our cPanel. However, this has not resolved the issue, and the problem persists.

My current MIME settings are

We have also checked the MIME settings, ensuring that only the .mjs extension is associated with test/javascript.

Could you please look into this further and suggest the next steps?

Thank you for your support.

Thank you for your earlier guidance.

We checked the config.inc.php file, and the mime_database_path setting is commented out by default:


[finfo]

; mime_database_path = /etc/magic.mime


We do not have a magic.mime file on our server. However, we uncommented it and cleared all caches and tested again, but the issue remains unresolved.

Additionally, we removed the pdf.js viewer plugin and attempted to install a new plugin. Although the installation was successful, the plugin does not appear in the “Installed Plugins” gallery.

Could you please advise on the following:

  1. Whether the missing magic.mime file could be causing this issue, or if PHP’s default fileinfo handling is sufficient.

  2. Why newly installed plugins might not appear in the plugin gallery despite successful installation.

Thank you for your support.

Hi @srinivasanchelliah,

None of those settings/actions will affect the problem you’re encountering with mjs files; be careful about changing unrelated settings/code, as you might cause problems elsewhere in the system.

If you are seeing the warning in your browser…

…then your web server needs to be configured to serve .mjs files with the application/javascript MIME type. Nothing else will fix the problem. This configuration is done outside of OJS, at the web server level, and the details of how to do this will vary from host to host.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

Thank you for your information. We will once again check with our hosting provider.

Please note that the server responded with a MIME type of “ “ (NULL) in our case.

Kindly let us know why the installed plugin (PDF JS) has not appeared in the plugin gallery despite successful installation.

Thank you in advance.

Hi @srinivasanchelliah,

How did you remove the PDF.js plugin, and how did you re-install it?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

First, I deleted the plugin by selecting the “delete” option from the “Installed Plugin” menu.

Then, using the “upload a new plugin” option, uploaded the downloaded plugin from (GitHub - pkp/pdfJsViewer: A pdf.js-based PDF viewer for OJS articles and issue galleys.) and saved it.

Thank you

Hi @srinivasanchelliah,

The best way to re-install that plugin after deleting it is to get the plugins/generic/pdfJsViewer directory from the .tar.gz download of the same version of OJS that you’re using. Move that directory’s contents from the download into the same location in your installation. That plugin comes with OJS, so we don’t make stand-alone packages of it available for all releases.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

Thank you for your guidance. I will download the .tar.gz file of the same OJS version we are using and copy the plugins/generic/pdfJsViewer directory contents into the corresponding location in our installation, as suggested.

After completing this step, I checked the system, and I can now confirm that the pdfJsViewer plugin is visible under the list of installed plugins. However, the PDF files are not opening within the browser.

I appreciate your clarification that this plugin is bundled with OJS and not available as a standalone package.

Thank you

Hi @srinivasanchelliah,

Are you still seeing the .mjs MIME type problem in your browser’s error console, or is something else happening?

Regards,
Alec Smecher
Public Knowledge Project Team

hi @asmecher

I have seen the following errors in the console.

pdf.mjs:1 Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of “”. Strict MIME type checking is enforced for module scripts per HTML spec.
viewer.mjs:1 Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of “”. Strict MIME type checking is enforced for module scripts per HTML spec.

I have shared your previous response with our host provider and am waiting for their reply.

Thank you

hi @asmecher

Finally, the articles are now opening in the browser without any issues.

Based on the information provided in the PKP forum, we had configured the MIME type to serve .mjs. However, the problem persisted because the browser cache had not been cleared. As suggested by the hosting provider, we cleared the browser cache, and the PDF files are now opening correctly.


The response from our hosting provider is as follows:

From the case details, I’m glad to know that you can now access the PDF file from your end. It seems that the below-provided Add Type code was added recently in the .htaccess file, which fixed the issue.

Here is the code:

AddType text/javascript .mjs
AddType application/javascript .mjs

Also, the error you experienced before when trying to access the PDF page might have been caused by your browser cache. Browser caching can sometimes prevent updated content from displaying correctly. Hence, we suggest clearing the browser cache, which will help you in accessing your website without any issues.


Thank you for the great support from @rcgillis @asmecher @Joshi

With Regards,

C. Srinivasan

2 Likes

This topic was automatically closed after 12 days. New replies are no longer allowed.