question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: implement service bindings + local mode `dev`

See original GitHub issue

Service bindings ([services]) works with remote mode in wrangler dev, we should figure out how to do the same for local mode. This is part of the broader picture for multi worker, but filing this as a followup for https://github.com/cloudflare/wrangler2/pull/906 anyway.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
threepointonecommented, Jul 29, 2022

Hey @chrstntdd, would you like to try the solution we just landed in wrangler@beta? You simply have to run wrangler dev --local on both workers in different terminal tabs, and they should automatically bind to each other.

1reaction
chrstntddcommented, May 30, 2022

Ah yeah, apologies for leaving that bit out. It’s not too involved at the moment, but it goes like this:

// env.ts

// `ENV` is injected by the build scripts with process.env.NODE_ENV or equivalent.
export const API_ENDPOINT = ENV === "production" ? "https://api.<WORKER>.com" : "http://localhost:3001"

And the usage within the application like so:

import { createResource } from "solid-js"

import { API_ENDPOINT } from "./config/env"
import { useFetch } from "./global-ctx"

export function App() {
  let fetch = useFetch()
  let [x] = createResource(`${API_ENDPOINT}/get-some-data`, async (key) => {
    let content = await fetch(key)
    return content
  })

  return (
    <section>
      <div>SSR data from worker:</div>
      <pre>{JSON.stringify(x(), null, 2)}</pre>
    </section>
  )
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to bind services in wrangler.toml? - Cloudflare Community
When trying to add a service binding through the dashboard, it says If this Worker is managed by Wrangler, add these variables to...
Read more >
Microsoft Privacy Statement
When a customer engages with Microsoft for professional services, we collect the name and contact data of the customer's designated point of contact...
Read more >
Release Notes | Internet Computer Home
feat : deploy NNS canisters​. A developer is now able to install NNS canisters, including back end canisters such as ledger and governance,...
Read more >
ContextActionService - Roblox Creator Documentation
To see a list of actions and their bound inputs, you can inspect the "Action Bindings" tab in the Developer Console (F9 while...
Read more >
MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables
Use REPAIR TABLE tbl_name QUICK . ft_query_expansion_limit. Command-Line Format, --ft-query-expansion-limit=#.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found