This is a simple Node.js application using Express.js to redirect all incoming requests to a specified URL defined in the environment variables.
To get the server running locally:
- Clone this repo
npm installto install all required dependencies- Set the
REDIRECT_URLenvironment variable to the URL where you want to redirect traffic - Optionally, set the
PORTenvironment variable to define which port the server should listen on (defaults to 3000) node index.jsto start the server
The application requires the following environment variables to be set:
REDIRECT_URL: The URL to which all traffic should be redirected.PORT(optional): The port on which the server will listen. Defaults to 3000 if not specified.
index.js: The entry point to the application. This file defines the Express server and the redirection logic.
- Redirects all incoming requests to the
REDIRECT_URLspecified in the environment variables. - Validates the
REDIRECT_URLto ensure it is a valid URL. - Logs the redirection target URL to the console.
- Exits the process if
REDIRECT_URLis not set or is invalid.
The application will log errors to the console and exit in the following situations:
- If
REDIRECT_URLis not set in the environment variables. - If
REDIRECT_URLis not a valid URL.
Once the server is running, any incoming requests will be redirected to the REDIRECT_URL with a 301 Moved Permanently status code.