This repository contains a simple maintenance page built with Next.js using TypeScript, Tailwind CSS, and the App Router. This page is designed to return a 503 Service Unavailable status code and display a customizable maintenance message, including a generic company logo.
- Installation
- Configuration
- Deployment to Cloudflare Pages
- Adding a Worker Route
- Customization
- AI Tools Disclosure
-
Clone the repository:
git clone https://github.com/licrow/my-maintenance-page.git cd my-maintenance-page -
Install dependencies:
Ensure you have Node.js and npm installed. Then, install the necessary dependencies:
npm install
-
Run the development server:
Start the development server to preview the maintenance page locally:
npm run dev
The page should be available at
http://localhost:3000.
The middleware.ts file handles setting the 503 status code and rewriting requests to the maintenance page.
To customize the logo:
- Replace the
logo.pngfile in thepublicdirectory with your company's logo. - The image will automatically be displayed on the maintenance page.
You can customize the styling of the page by modifying the Tailwind CSS classes in app/page.tsx. Tailwind CSS is already configured in the project, so any changes you make will be reflected immediately.
To deploy this maintenance page on Cloudflare Pages, follow these steps:
-
Login to Cloudflare:
Log in to your Cloudflare account at https://dash.cloudflare.com.
-
Create a new Cloudflare Pages project:
- Go to the "Pages" section in the Cloudflare dashboard.
- Click on "Create a project".
- Connect your GitHub repository containing the maintenance page code.
-
Configure build settings:
- Build command:
npm run build - Output directory:
.next
Make sure the output directory matches the default for Next.js when building for static export.
- Build command:
-
Deploy the project:
Once configured, trigger a deployment. Cloudflare Pages will build and deploy the maintenance page.
-
Custom Domain (Optional):
If you want to deploy this under a custom domain, configure your domain in the Cloudflare dashboard and link it to your Cloudflare Pages project.
To add a worker route to your Pages site, follow these steps:
-
Copy the worker script:
Copy the contents of the
WORKERSCRIPTfile from the repository. This script handles routing and content rewriting for the maintenance page. -
Update the
maintenancePageUrlvariable:In the worker script, replace the value of
maintenancePageUrlwith the actual URL of your deployed maintenance page. -
Configure the route in Cloudflare:
- Go to your Cloudflare dashboard and navigate to the "Workers & Pages" section.
- Find your Pages project and click on it.
- Go to the "Settings" tab and scroll down to the "Functions" section.
- Under "Routes", add a new route:
- Route:
test.example.com/* - Worker: Select your Pages project
- Route:
-
Deploy your changes:
Add the worker script to your Cloudflare Pages project as instructed in the Cloudflare dashboard. Cloudflare Pages will automatically deploy the changes.
Now, when you access test.example.com, the worker will route the request to your maintenance page.
You can customize the text and layout of the maintenance page by editing the app/page.tsx file. The content is structured in a way that allows easy updates to the maintenance message, styling, and structure.
If you want to display an estimated time for how long the maintenance will last, simply update the text in the page.tsx component under the <p> tag with the class "text-sm text-gray-500".
This project was developed with the assistance of AI tools, specifically OpenAI's ChatGPT, which was used to generate code, provide architectural guidance, and draft documentation. The generated content has been reviewed and modified to meet the specific requirements of this project.