ExpressJS sample app works on local machine but fails when deployed

I am trying to experiment with integrating Auth0 to create a ‘members-only’ area on a website. I downloaded the NodeJS with Express sample application to test making a connection with the Auth0 tenancy I created.
If I run the sample on my local development machine, configured to run against an application setup in my tenancy it works.
I followed the instructions and setup the Allowed Callback and Logout URLs on the application settings in the Auth0 dashboard, and copied the clientid, secret and issuer base URL from the dashboard and added them to the .env file.
When I run this locally, I am able to log in using the login page.
I then uploaded the same code to the shared web host using cPanel and followed the instructions to install the app. The app wouldn’t start, so I had to add an entry for base URL in addition to the issuer base URL as it was complaining that it was missing when used in production mode.
This only got me to the next error; TypeError: “issuerBaseURL” must be a valid uri
Both the local development app and the deployed app use the same URI string but the deployed app refuses to accept it. I have added the equivalent URLs to the CallBack and LogOut URLS for the deployed version.

I am obviously missing something, but I don’t know what. The only other difference is that I am using HTTPS for the deployed version and HTTP for the local, but the issuer base URL uses HTTPS in both cases.

Any assistance would be gratefully received.

SOLVED:

There was an issue with environment variables set via the cPanel Node.JS configuration pages. Which I first used when I could not see the .env file, as it was hidden. Once I found the .env file and corrected the entries in there I removed the environment variables from the cPanel Node.JS configuration pages. Unfortunately cPanel stored these environment variables in the .htaccess file and didn’t remove them when they were deleted.
Cleaning the deployment and removing the .htaccess file before redeploying resolved the issue.
The sample app now works as expected.

Kind regards
Darren

Hello @developer21,

Welcome to the Auth0 community!

Thank you for sharing your solution with the community.

Thanks,
Timotei

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.