This is the front-end for a URL-shortner I built.
The application is live at: https://mudit-51-url-shortner.netlify.app/
Built using React.
Using the website to create a URL:
- The user inputs the URL into the text box. The application checks whether it is a valid URL or not. One con currently is that every URL is required to be prefaced by
https://
orhttp://
. I hope to fix this in the near future. - If a valid URL is entered, the appliation makes a
POST
request to the backend. ThePOST
request body contains the input URL. - The backend queries the database if a Base62 "hash" for the given website exists. This application uses MongoDB.
- If hash exists, then it is returned, and the shortened URL is displayed. If it does not exist, it is generated and then returned to the user. The database is then updated with the hash for that particular website.
Using a shortened URL generated by the website:
- The application takes everything entered after the domain as the hash, and then sends a
GET
request with that hash to the backend. - The backend queries the database for that hash.
- If a website associated with that hash exists, then the
GET
request is redirected to that website URL. Otherwise the user is redirected to an error page.
- Node.js (>=0.10.0)
- React Router
- Tailwind CSS
-
Clone the project.
-
Install dependencies using
npm install
-
You have two choices now:
- Start a development server to view the application using
npm start
- Build the application using
npm build
and then serve it using a static server
Note:
- This only runs the front-end of the application. The application will not be functional, ie. it will not give an output for any input.
- Cloning and running the backend is necessary to run the entire application locally.
- You will have to change the fetch URL target in
Root.jsx
andRedirect.jsx
to alocalhost
address to run the entire application locally.
- Start a development server to view the application using
readme still a wip