Hello lovely developers! I am experiencing a problem with trying to house my javascript file separate from my .ejs files. In this example, I am point my script tag to "../client/index.js" and I know for a fact this is the location of my javascript file. BUT in this case it thinks I am pointing to localhost:5000/client/index.js when it should be pointing to the files in my internal file structure.
I have never experienced an issue like this. The weird thing is when I follow the link is VS code, it takes me to the correct file location. The problem only occurs when the link is present in the browser. I've tried doing some research on correctly orienting script tags, and I cannot for the life of me find out how to get this working.
Thank you so much your time, I appreciate it!
../
means "Go up one level".
You are using it when you are already at /
so there isn't a level to go up.
The ../
is therefore discarded.
It would be a security problem if you could craft a URL that would go above the server root and access any files on the computer running the website.
If you want to access the JS file then you will need to put it somewhere where it has a URL, and then use that URL.