• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue relative paths not functioning after porting to Plesk

pangit

New Pleskian
Greetings,

I am new to Plesk, this is my initial posting.

I developed a website locally using my "localhost" and created all the site links, buttons, etc using a relative path structure. My server code is written in Node.js/Express. I am also using .ejs for a template engine...therefore all my server webpages are in a folder called "views/pages". My dedicated server is using Plesk Obsidian 18.0.36.

My Express routes are similar to this:

app.get('/', function (req, res) { res.render('pages/_splash'); }); app.get('/_landing', function(req, res) { res.render('pages/_landing', {user_stat: _subscriber}); });

When I first navigate to the site URL the route for "/" is called, and the page ("_splash.ejs") is displayed...without any problems at all, it works perfectly as expected. It is on this page I have a button, which is coded as here:

<a href="/_landing" class="btn btn-primary" role="button">Enter Site</a>

A 'press' of this button SHOULD call the route called "/_landing" and proceed to render the page as directed in the code...however it does NOT. Instead it wants to load "https://mydomain.com/_landing". Upon doing so of course I get a "404 Page Not Found" error...which is understandable. What is not understandable is why the Express routing structure is suddenly ignored.

Why is this happening? Everything worked fine on my development ('localhost') machine, the problem only occurs now that I have uploaded to a Plesk server. For some reason the Node.js Express routes are now being ignored. I did find a posting on the Plesk Forum here "Resolved - use nodejs and problem with express routing" which seems very similar to my issue...however my modification of the "web.config" file (as indicated in the post) did not solve the issue.

Any help or suggestions would be GREATLY appreciated. This is extremely frustrating and I am currently at a loss on how to correct this issue. It is likely this is some issue with "web.config" or Nginx/Apache configuration? ...Especially since these file(s) are only associated with Plesk...and were non existant on my 'localhost' machine.

I thank you in advance.

Regards
 
It turned out to be a 'known' issue with Plesk tech support. A Plesk technician admitted this situation is one 'which is yet to be fixed'. A rewrite rule needs to be added to the 'web.config' file...something like:

"REWRITE RULE" AS WRITTEN INTO "WEB.CONFIG" (AFTER "/httpErrors" AND WITHIN "/system.webServer")...!

<rewrite>
<rules>
<remove name="startup-file for site #1" />
<rule name="startup-file for site #1">
<match url="/*" />
<conditions />
<serverVariables />
<action type="Rewrite" url="/test.js" />
</rule>
</rules>
</rewrite>

Where the url '/test.js' is changed to the name of your Node JS startup file used as your backend server code. If you are having difficulty I believe you can get a month of free tech Plesk support to get it resolved with the help of a technician. The code I posted above should solve the issue for you. If you do end up requiring to contact Plesk support then it might help to reference the following error code I was given: "This rule is not compatible with the application due to Node.js extension bug #EXTNODEJS-46, which is yet to be fixed."

Regards
 
Back
Top