This is a simple URL shortener application for Code for Fun that uses the short.io API. It includes a basic password protection screen before allowing users to shorten URLs. The application features a salmon color theme.
- Basic password protection
- URL shortening using short.io API
- Optional custom slug support
- Copy-to-clipboard functionality
- Responsive design
- Salmon color theme
- API key storage (server-side only)
- Netlify serverless functions (no spin-down time)
-
Clone this repository
-
Install dependencies:
npm install -
Create a
.envfile with the following variables:PASSWORD=your_password SHORT_IO_API_KEY=your_short_io_api_key SHORT_DOMAIN=your_short_domain.example.com -
Run the development server:
npm run dev -
Open your browser to http://localhost:8888
- Make sure your GitHub repository is up to date
- Log in to Netlify and click "New site from Git"
- Connect your GitHub repository
- Configuration settings will be automatically applied from the netlify.toml file
- Add the following environment variables in the Netlify Dashboard:
PASSWORD: Your desired passwordSHORT_IO_API_KEY: Your short.io API keySHORT_DOMAIN: Your short domain (e.g., "short.example.com")
- Click "Deploy site"
Note: After deployment, you'll need to set up the environment variables mentioned above in your Netlify dashboard.
This implementation uses a simple approach:
- The password is stored as an environment variable
- The short.io API key is stored server-side and never exposed to the client
- Password validation happens server-side
- Leverages Netlify's serverless functions (which don't have spin-down time like Render's free tier)
This is suitable for basic access control, but not for securing highly sensitive information.
- Open the website and enter the password
- Enter the URL you want to shorten
- (Optional) Enter a custom slug
- Click "Shorten URL"
- Copy the shortened URL using the "Copy" button