첫 Worker 배포하기
Worker를 Cloudflare의 엣지 네트워크에 배포하고 실제 환경에서 기능을 검증하는 단계를 배웁니다.
첫 Worker 배포하기은(는) CoddyKit의 무료 Edge Computing with Cloudflare Workers & Deno 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Edge Computing with Cloudflare Workers & Deno 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Edge Computing with Cloudflare Workers & Deno 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Ready to Go Live!
You've learned to set up your environment and write a basic Cloudflare Worker. Now, let's make it accessible to the world!
Deploying your Worker means pushing your code to Cloudflare's global network, making it run at the 'edge' – closer to your users.
Before You Publish
Before deploying, ensure you've completed a couple of essential steps:
- Cloudflare Account: You need an active Cloudflare account.
- Wrangler Login: You must be logged in to Wrangler CLI. If not, run
wrangler loginto authenticate with your Cloudflare account.
These prerequisites ensure Wrangler has permission to deploy to your account.
The `wrangler publish` Command
The core command for deploying your Cloudflare Worker is wrangler publish.
You run this command from within your Worker project directory. It handles everything from bundling your code to updating it on Cloudflare's edge network.
What `publish` Does
When you run wrangler publish, several things happen:
- Bundling: Your Worker code (often JavaScript or TypeScript) is processed and optimized.
- Uploading: The bundled code is securely uploaded to Cloudflare's global network.
- Deployment: Cloudflare then makes your Worker live, routing requests to it from the edge closest to the user.
This process is usually very fast!
Our Example Worker
Let's use a simple 'Hello from the Edge!' Worker for deployment. This Worker responds to any incoming request with a plain text message.
Try running this example locally first, then we'll deploy it.
export default {
async fetch(request) {
return new Response("Hello from the Edge!", {
headers: { 'content-type': 'text/plain' },
});
},
};Deploying Your Worker
Assuming you have the example Worker code in a project folder (e.g., my-first-worker) and have run wrangler login, navigate to that directory in your terminal.
Then, simply execute the publish command:
cd my-first-worker
wrangler publishDeployment Confirmation
After running wrangler publish, you'll see output in your terminal indicating success. It will also provide the public URL where your Worker is now live.
This URL typically looks like https://your-worker-name.your-username.workers.dev.
Testing Your Live Worker
Now that your Worker is deployed, let's test it! You can use your web browser or a command-line tool like curl.
Open your browser and navigate to the URL provided by wrangler publish. You should see 'Hello from the Edge!'.
curl https://your-worker-name.your-username.workers.devUpdating Your Worker
The beauty of Workers is how easy it is to update them. If you make changes to your Worker's code, simply save your changes and run wrangler publish again.
Cloudflare will automatically update your live Worker with the new code, often within seconds!
Deployment Process Check
You've just deployed your first Worker! Let's quickly review the steps involved.
Recap: Your Worker is Live!
Congratulations! You've successfully deployed your first Cloudflare Worker to the edge network.
- You used
wrangler publishto deploy your code. - You verified its live functionality via its public URL.
- You learned that updates are as simple as running
publishagain.
Your code is now running globally, closer to users than ever before!
자주 묻는 질문
“첫 Worker 배포하기” 강의는 무료인가요?
네 — “첫 Worker 배포하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Edge Computing with Cloudflare Workers & Deno 강의 전체를 잠금 해제할 수 있습니다. Edge Computing with Cloudflare Workers & Deno 강의에는 총 4개의 강의가 포함되어 있습니다.
“첫 Worker 배포하기”에서 뭘 배우나요?
Worker를 Cloudflare의 엣지 네트워크에 배포하고 실제 환경에서 기능을 검증하는 단계를 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Edge Computing with Cloudflare Workers & Deno을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Edge Computing with Cloudflare Workers & Deno을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Edge Computing with Cloudflare Workers & Deno은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“첫 Worker 배포하기” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Edge Computing with Cloudflare Workers & Deno 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Edge Computing with Cloudflare Workers & Deno 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Worker 환경 설정하기
- HTTP 요청 처리하기
- 첫 Worker 배포하기
- 워커의 환경 변수 및 비밀값