0Pricing
Edge Computing with Cloudflare Workers & Deno · Lezione

Distribuire il primo Worker

Impari i passaggi per distribuire il suo Worker sulla rete edge di Cloudflare e verificarne il funzionamento dal vivo.

Distribuire il primo Worker è una lezione Edge Computing with Cloudflare Workers & Deno gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Edge Computing with Cloudflare Workers & Deno, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Edge Computing with Cloudflare Workers & Deno include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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 login to 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 publish

Deployment 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.dev

Updating 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 publish to deploy your code.
  • You verified its live functionality via its public URL.
  • You learned that updates are as simple as running publish again.

Your code is now running globally, closer to users than ever before!

Domande Frequenti

La lezione «Distribuire il primo Worker» è gratuita?

Sì — il testo completo di «Distribuire il primo Worker» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Edge Computing with Cloudflare Workers & Deno, passa a CoddyKit PRO. Il corso Edge Computing with Cloudflare Workers & Deno include 4 lezioni in totale.

Cosa imparerò in «Distribuire il primo Worker»?

Impari i passaggi per distribuire il suo Worker sulla rete edge di Cloudflare e verificarne il funzionamento dal vivo. Eserciti Edge Computing with Cloudflare Workers & Deno con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Edge Computing with Cloudflare Workers & Deno?

Non è richiesta alcuna esperienza precedente. Edge Computing with Cloudflare Workers & Deno su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Distribuire il primo Worker»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Edge Computing with Cloudflare Workers & Deno?

Sì. Ogni lezione Edge Computing with Cloudflare Workers & Deno include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Configurare l'ambiente Worker
  2. Gestire le richieste HTTP
  3. Distribuire il primo Worker
  4. Variabili d’ambiente e segreti nei Worker
← Torna a Edge Computing with Cloudflare Workers & Deno