Search code examples
node.jsexpressserverrelative-pathplesk

relative paths not functioning after site files uploaded to server


I developed a website locally using "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".

Using this structure, for example, I have a button with a link coded as:

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

On my development 'localhost' machine this was sufficient to call the '_landing' route in my server script which would then render the proper page to be served...without any difficulty. The server code would read something like this:

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

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

Now I have uploaded my site files to a Windows server using Plesk software. The site files and folders are located in a directory named "httpdocs". It now seems my relative path links are broken. Using the button link above again as an example for some reason it now wants to route to "https://example.com/_landing"...which is obviously not correct. Why does it seem the relative path now seems to ignore the route call in Node.js...?

Any advice greatly appreciated, I am having extreme difficulty posting my site online due to a myriad of undocumented problems like this...posting a request to my server support will be useless since they do not respond to "coding issues". I thank you in advance.


Solution

  • For anybody that may be interested after several weeks I was able to determine the problem here. I eventually enlisted Plesk support in an effort to solve this issue. It was confirmed to me by a Plesk technician that my described issue was caused by a bug in the Plesk software platform.

    The solution to resolve the bug was to insert some additional code in the 'web.config' file as follows:

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

    This code is to appear in the 'web.config' file AFTER "/httpErrors" AND WITHIN "/system.webServer"...the 'test2.js' should be set to the JS script file for your domain.