Getting name of calling .ejs file from within a server connect

First time poster here. Running NodeJS, apache, routing, MySQL, and a local deployment.

I'm loading a server connect at the top of my .ejs page. Let's call it 'http://.../:my-company'. The SC needs to get the path from the dynamic URL of the calling .ejs page. Yesterday, I had it working using {{$_SERVER.URL.split('/').last(1).toString()}}. This morning, I made some changes to my routes and pushed an update of the routing rules. Today, now instead of the SC returning the correct path from the calling file, it's returning the path to itself. How might have uploading new routing rules changed this behavior? All I did was move some pages from root below a new path called /zone/.

TIA.

This variable always refers to the current URL/route, not the location of the ejs file.

It might be possible to get the location of the ejs file, but you might need to investigate the actual ejs documentation rather than Wappler's.

Also, if you search my posts, search for "PATH_INFO", you'll find the proper way to get the current route

This is Apple's post that helped me - Security Restrict Global Restriction on API actions - #2 by Apple

2 Likes

Appreciate the help. After looking into the ejs docs (AKA chatGPT), it seems getting the URL of the calling ejs file from within the API is not allowed. I tried all possible $_SERVER variables.

Looks like I have to rethink the design approach.