透過 100+ 個技巧的集合來學習 Nuxt!

nuxt-localtunnel
@nuxtus/nuxt-localtunnel

自動將您的 Nuxt localhost 對外公開。

Nuxt Localtunnel

一個 Nuxt 模組,用於自動運行 localtunnnel,以將您的 Nuxt 開發實例對外公開。

允許完整配置所有 localtunnel 配置選項,包括 https

安裝

npm install @nuxtus/nuxt-localtunnel

編輯您的 nuxt.config.ts 並新增 @nuxtus/nuxt-localtunnel 模組

modules: [
  '@nuxtus/nuxt-localtunnel'
],
localtunnel: {} // Localtunnel config options go here (see below)

然後像平常一樣啟動 Nuxt npm run dev,您將獲得一個額外的(用於訪問您的開發站點的外部 URL)。

設定

所有 localtunnel 配置選項都可透過 nuxt.config.ts 檔案的 localtunnel 屬性接受

  • port (數字) 要透過 localtunnel 公開的本地端口號碼。
  • subdomain (字串) 在代理伺服器上請求特定的子網域。注意 您實際上可能無法收到此名稱,具體取決於可用性。
  • host (字串) 上游代理伺服器的 URL。預設為 https://localtunnel.me
  • local_host (字串) 代理到此主機名稱而不是 localhost。這也會導致 Host 標頭在代理請求中被重寫為此值。
  • local_https (布林值) 啟用隧道連線到本地 HTTPS 伺服器。
  • local_cert (字串) 本地 HTTPS 伺服器的憑證 PEM 檔案路徑。
  • local_key (字串) 本地 HTTPS 伺服器的憑證金鑰檔案路徑。
  • local_ca (字串) 自簽憑證的憑證授權檔案路徑。
  • allow_invalid_cert (布林值) 停用本地 HTTPS 伺服器的憑證檢查(忽略 cert/key/ca 選項)。

有關憑證選項的詳細資訊,請參閱 tls.createSecureContext

開發

  • 運行 npm run dev:prepare 以生成類型定義檔案。
  • 使用 npm run dev 在開發模式下啟動 playground