Skip to content

Commit 680a04c

Browse files
Update README.md
1 parent b907e62 commit 680a04c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ Serverless URL shortener based on raw text link via cloudflare workers
44

55
This JavaScript script uses the Fetch API and the `addEventListener` function to handle a request event and redirect the user to a specific URL based on a unique ID passed in the request URL.
66

7+
# How to deploy to Cloudflare and create an account
8+
9+
## Creating a Cloudflare account
10+
1. Go to the Cloudflare website at https://www.cloudflare.com/.
11+
2. Click on the "Sign Up" button in the top right corner of the page.
12+
3. Follow the prompts to create your account.
13+
14+
## Deploying to Cloudflare
15+
1. Login to your Cloudflare account.
16+
2. Go to the "Workers" section of the Cloudflare dashboard.
17+
3. Click on the "Create a Worker" button.
18+
4. In the "Script" section, copy the contents of your `worker.js` file.
19+
5. Replace the 12th line of the `worker.js` file with the URL of your hosted application. For example:
20+
21+
```
22+
const urlList = await fetch('https://raw.githubusercontent.com/developeranaz/Serverless-URL-Shortner/main/urls.txt')
23+
24+
```
25+
26+
6. Click on the "Save and Deploy" button.
27+
7. Test your worker by sending a request to your Cloudflare worker URL.
28+
29+
Congratulations! Your application is now deployed to Cloudflare.
30+
31+
32+
733
## How it works
834

935
1. The script listens for a `fetch` event using the `addEventListener` function and calls the `handleRequest` function when the event is triggered. The request object is passed to the `handleRequest` function as an argument.

0 commit comments

Comments
 (0)