SOLVED: Upgrade from OJS 3.1.2.4 to OJS 3.2.1.2: problems with url api in back-office

Hello,

I wish everyone a happy new year better than last year.

We officialy upgraded from OJS 3.1.2.4 to OJS 3.2.1.2 today, but we encountered some serious problems with url api in back-office.

The front office is working fine.
In the back-office, we having sometimes this error: An unexpected error has occurred. Please reload the page and try again.

For example when we want to display submissions page.

There is in error log file:
404 Not Found, referer: https://journal-domain1.fr/submissions

We have javascript errors in console window like this one:
Uncaught TypeError: b is undefined
modalOpen https://journal-domain1.fr/js/pkp.min.js?v=3.2.1.2:316
ajaxErrorCallback https://journal-domain1.fr/js/build.js?v=3.2.1.2:8
error https://journal-domain1.fr/js/build.js?v=3.2.1.2:8
jQuery 4

And in the network tab of console, there are some url like this one:
https://journal-domain1.fr/api/v1/stats/submissions?status=1&searchPhrase=&count=20&offset=0&=1609758145263

But when I enter this URL in a browser, it is automaticaly rewrite with adding the contextPath of the journal (“journal1”) like this:
https://journal-domain1.fr/journal1/api/v1/stats/submissions?status=1&searchPhrase=&count=20&offset=0&=1609758145263

And it displays a page with: 404 Not Found

We didn’t have this problem in OJS 3.1.2.4 and in our test platform in OJS 3.2.1.2.

The difference is we have on our production platform journals with their own domain and rewrite rules in .htaccess file like this:

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/journal1/$1 [QSA,L]

Can you please help me to solve this problem ?

Thanks in advance for your answer.
Best regards.
Helene

Hi @hcl

It is a well known topic and occurs when the journal path (prefix) is removed via htaccess rules.

More detailed discussion is here.

I did revert back to use journal path, and updated all DOIs. But still waiting for a better solution.

Regards,

Hi @drugurkocak, Hi @asmecher,

I am a bit afraid on what @drugurkocak says.
I knew the existence of this kind of problems of rewrite rules.
But it was working fine for us until OJS 3.1.2.4.
What changed in OJS 3.2.1.2 for not working anymore in our case?
Can I change something in my current setting to make it work again ?

Thanks again for your help.
Helene

Hi @hcl,

I haven’t looked at this for a while, but I think you’ll have to adapt and add the Rewrite API calls to subdomain journals part of the rules suggested by @ajnyga on the linked issue.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi again @drugurkocak, @asmecher,

I found the solution!
Thanks to both of you to remind me the linked issue.
I indeed had to adapt my .htaccess file and add the Rewrite API calls to subdomain journals part of the rules.

I added the 2 rules in bold in the text:
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteRule ^api/v1(.*)$ /index.php/journal1/api/v1$1 [R,L]
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/journal1/$1 [QSA,L]

Kind regards.
Helene

Hi @hcl

Can you inform me If you can successfully modify website settings and save them, after applying these rules.
I have tried several times before.

RewriteRule ^api/v1(.*)$ /index.php/journal1/api/v1$1 [R,L]

I actually applied that rule, the Kbodarwe’s solution but no cure.

RewriteRule ^api/v1(.*)$ index.php/journal/api/v1$1 [R,L]

I think this supresses some backend error messages, but I couldn’t even change the theme eventhough I get no error messages. So, I had to remove the rules at that time.

Regards,

Hi @drugurkocak,

Both rules worked for me:
RewriteRule ^api/v1(.)$ index.php/journal1/api/v1$1 [R,L]
RewriteRule ^api/v1(.
)$ /index.php/journal1/api/v1$1 [R,L]

But to make it work, I had to add this rule twice before and after:
RewriteCond %{SERVER_NAME} ^journal-domain1.fr

I hope it will help.
Helene

Hi @hcl

I was happy to hear that you have succeeded. But my trials with your rules give the same error and fail.
I can’t change the theme, and my settings are not saved although the message says it was saved :slight_smile:
I don’t want to keep on talking about the same things because your server configuration might be better, etc
 I applied these rules to httpd.conf file, not to htaccess.

The [probable] OJS portal that @ajnyga manages Journals.fi still seem to be working on OJS 3.1.x
I follow him because I also wait for OJS 3.2 compatible version of Forthcoming plugin. May be I am wrong. We are all having hard days now, and only wish healthy days for everyone.

Take care.

Screen Shot 2021-01-04 at 23.53.08

Screen Shot 2021-01-04 at 23.53.46

Screen Shot 2021-01-04 at 23.53.55

Dear @hcl and @NateWr

In order to test and apply your htaccess rules, I made a clean (ojs 3.2.1.2) install at; https://www.cancer-research.net

I set up 4 journals, 3 having its own domain.

I am actually at the same point where I left, but I can modify settings, submit articles, and publish issues.
When I try to upload a homepage image or journal thumbnail at Website Settings → Appearance → Setup page, I get en error. The error is “Failed to load resource: the server responded with a status of 403 (Forbidden)” with the link to https://www.adlibilimler.online/jfs/api/v1/temporaryFiles
When I click the link, I get {"error":"api.404.endpointNotFound","errorMessage":"The requested URL was not recognized."} message in a blank white page.
I’ve never felt so close to the solution before.
But I am not a programmer and can’t go any further.
If anyone help with this, I will be very grateful and will share the solution for others to benefit as well.
I may send any user credentials via personal message if needed.
Best regards,
Screen Shot 2021-01-10 at 14.10.06

You need to have a look at the rewrite rule for the api.
https://www.adlibilimler.online works fine but https://www.adlibilimler.online/jfs/api/v1/temporaryFiles still contains the /jfs/ part.
I had success with this one: [OJS 3.2.0.3] Error on Submission Page - #24 by KBodarwe

1 Like

Thank you very much @klausru
I will try your suggestion,
Regards,

Dear @klausru
Thank you very much for your suggestion. Now, I can upload the journal thumbnail and homepage image without any errors. I am very happy.

I will test the site for 2 to 3 day with all editorial processes, and share the details and configuration here.
Best regards,

1 Like

Hi all,

After some hard :slight_smile: tests, I want to share htaccess configuration that I could successfully removed index.php and journal path on a multijournal & multidomain OJS installation.

I am aware that this solution my be limited to my server configuration, so I will try to share all details related to OJS environment.

I need to say that I couldn’t get success with this model on a single journal setup.
Besides the site domain, at least a different domain is needed for the journal.

In this test scenario, cancer-research.net is the main domain & ojs 3 is installed on it.
Other domains are alias of cancer-research.net with their own mail acccounts.

In this scenario, I can delete existing or generate a new journal, modify all journal settings on their own settings panel and perform all editorial processes. The mail system also runs well.

The only error I get is “Access to XMLHttpRequest at 
 has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”

This error at the settings wizard at site administration section is a well known error due to CORS policy and it is the topic of another discussion.

If anyone wants to examine and make some tests, those are the usernames:

author user : author password: 123456
reviewer user : reviewer password: 123456
editor user : editor password: 123456
Journal manager : manager password: 123456

Test Journal of Cancer Research (https://www.cancer-research.net/tjcr) and Test Journal of Social Sciences (https://www.cancer-research.net/tjss) don’t have their own domains, but all others have their own domains (please look at config).

 base_url = "https://www.cancer-research.net"
 base_url[index] = https://www.cancer-research.net/index
 base_url[tjcr] = https://www.cancer-research.net/tjcr
 base_url[tjss] = https://www.cancer-research.net/tjss
 base_url[jfm] = https://www.adlitip.net
 base_url[jfs] = https://www.adlibilimler.online
 base_url[cmj] = https://citymedicaljournal.xyz
 base_url[jcr] = https://www.cancer-research.xyz

The Server Configuration:

Operating system : CentOS Linux 7.9.2009
Webmin version : 1.962
Virtualmin version : 6.14
Kernel and CPU : Linux 3.10.0-1160.11.1.el7.x86_64 on x86_64

Apache version : 2.4.6
PHP versions : 7.2.24, 7.3.20, 7.4.14
MySQL (MariaDB) version : 10.4.17

Modules for PHP 7.4: bcmath bz2 calendar cgi-fcgi Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv imap intl json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix pspell readline Reflection session shmop SimpleXML soap sockets sodium SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib

Pear modules for PHP 7: Archive_Tar Console_Getopt PEAR PEAR_Manpages Structures_Graph XML_Util

PHP script execution mode : CGI wrapper (run as virtual server owner)

htaccess directives for virtual host:

 Options +ExecCGI +FollowSymLinks +IncludesNOEXEC -Indexes +SymLinksIfOwnerMatch
  allow from all
 AllowOverride All
 Require all granted

htaccess directives for userdir:

<Directory "/home/*/public_html">
     Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
     allow from all
    AllowOverride all
    Require all granted
</Directory>

#htaccess directives to remove journal path and index.php on OJS 3.2.1.2 

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /


# Rules for  Test Journal of Forensic Medicine 

RewriteCond %{SERVER_NAME} ^(www\.)?adlitip.net
RewriteRule ^api/v1(.*)$ index.php/jfm/api/v1$1 [L,R=307]
RewriteCond %{SERVER_NAME} ^(www\.)?adlitip.net
RewriteCond %{REQUEST_URI} !/jfm/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/jfm/$1 [L]


# Rules for  Test Journal of Cancer Sciences 

RewriteCond %{SERVER_NAME} ^(www\.)?cancer-research.xyz
RewriteRule ^api/v1(.*)$ index.php/jcr/api/v1$1 [L,R=307]
RewriteCond %{SERVER_NAME} ^(www\.)?cancer-research.xyz
RewriteCond %{REQUEST_URI} !/jcr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/jcr/$1 [L]


	
# Rules for  Test City Medical Journal

RewriteCond %{SERVER_NAME} ^(www\.)?citymedicaljournal.xyz
RewriteRule ^api/v1(.*)$ index.php/cmj/api/v1$1 [L,R=307]
RewriteCond %{SERVER_NAME} ^(www\.)?citymedicaljournal.xyz
RewriteCond %{REQUEST_URI} !/cmj/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/cmj/$1 [L]



# Rules for Test Journal of Forensic Sciences
RewriteCond %{SERVER_NAME} ^(www\.)?adlibilimler.online
RewriteRule ^api/v1(.*)$ index.php/jfs/api/v1$1 [L,R=307]
RewriteCond %{SERVER_NAME} ^(www\.)?adlibilimler.online
RewriteCond %{REQUEST_URI} !/jfs/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/jfs/$1 [L]


# Rules for Test Journal that doesnt have own domains
RewriteRule ^api/v1(.*)$ index.php/\b(tjcr|tjss)\b/api/v1$1 [L,R=307]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(tjcr|tjss|another_journal)(.*)$ /index.php/$1$2 [L]
RewriteRule ^api/v1(.*)$ index.php/index/api/v1$1 [L,R=307]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]


</IfModule>

; OJS 3 config.inc.php configuration

; The canonical URL to the OJS installation (excluding the trailing slash)
 base_url = "https://www.cancer-research.net"

allow_url_fopen = Off

 base_url[index] = https://www.cancer-research.net/index
 base_url[tjcr] = https://www.cancer-research.net/tjcr
 base_url[tjss] = https://www.cancer-research.net/tjss
 base_url[jfm] = https://www.adlitip.net
 base_url[jfs] = https://www.adlibilimler.online
 base_url[cmj] = https://citymedicaljournal.xyz
 base_url[jcr] = https://www.cancer-research.xyz


restful_urls = On
1 Like