The Client Information App is a simple Node.js application that displays client-specific information such as IP address, browser details, and geolocation data. This application is designed for educational purposes, allowing students to learn how to work with Node.js, fetch client information, and deploy to Google Cloud.
- Displays client's IP address, browser information, and operating system.
- Fetches geolocation data (city, region, country, latitude, and longitude) based on the IP address.
- Styled with Bootstrap for a simple and clean user interface.
Before you begin, ensure you have the following installed:
- Node.js (version 14 or higher recommended)
- npm (comes with Node.js)
- Google Cloud SDK (for deploying to Google App Engine)
To clone this repository to your local machine, run:
git clone <repository-url>
cd client-info-appReplace <repository-url> with the actual URL of the repository.
Navigate to the project directory and install the required Node.js packages:
npm installThis command installs the necessary dependencies listed in the package.json file, including Express, request-ip, and axios.
To start the application on your local machine, use the following command:
node app.jsBy default, the app will run on http://localhost:3000. Open this URL in your browser to see the client information displayed.
You can deploy this application to Google Cloud using Google App Engine. Follow these steps:
- Go to Google Cloud Console.
- Create a new project or select an existing project.
- Make sure App Engine and Cloud Build APIs are enabled.
In the root directory of your project, create a file named app.yaml with the following content:
runtime: nodejs20
instance_class: F1
env: standardThis configuration file specifies the runtime environment and instance class for the app on Google App Engine.
-
Authenticate your Google Cloud CLI:
gcloud auth login
-
Set the project ID (replace
your-project-idwith your actual Google Cloud Project ID):gcloud config set project your-project-id -
Deploy the application:
gcloud app deploy
-
Confirm the deployment if prompted. Once completed, Google will provide a URL for your deployed application.
After successful deployment, visit the provided URL to see your app running on Google App Engine. The application should now display the IP, browser information, and geolocation data for each visitor.
- The app may display "localhost" as the IP address when running locally. Real IP data is displayed when the app is hosted on a server.
- Location information will show "N/A" if it’s unable to fetch data based on the IP address.
After completing the deployment exercise, it's essential to clean up the resources to avoid unnecessary charges on your Google Cloud account. Follow these steps to remove the resources:
-
Delete the App Engine Application:
- Open the Google Cloud Console.
- Go to App Engine > Settings.
- Click Disable Application. This will stop all running services and delete the App Engine instance.
-
Delete the Google Cloud Project:
- If the project was created specifically for this exercise and is no longer needed, you can delete the entire project, which will remove all resources associated with it.
- Go to IAM & Admin > Manage Resources in the Cloud Console.
- Select the project used for this exercise.
- Click Delete and confirm the action.
This cleanup will ensure that no unnecessary charges are incurred and that your Google Cloud credits are preserved for future projects.
This project is licensed under the MIT License. Feel free to use it for educational purposes.