https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • c

    Chaika

    04/30/2023, 3:37 AM
    Custom Domains and Routes are two different ways to use Workers, Custom Domains are more managed and automatically create a DNS Record for you and a certificate, they become the origin on the host. Routes are more flexible and can be used on specific paths/wildcards/etc. You can use either on your domain
  • c

    Chaika

    04/30/2023, 3:41 AM
    If your goal is to make a worker that parses out the specific subdomain, fetch a sub directory based on it or any other endpoint that's possible with workers sure. The one complex part may be redirecting the links of the html/resources to be the subdomain rather then the directory, you can do some stuff with html rewriter though, depends on how complex your app is
  • s

    Serby

    04/30/2023, 3:41 AM
    heh this is where im confused I think... i have it working in my personal network but I use python and hypercorn /uvicorn and I just did a CORS * and made a starlette middleware that regex and strip the main domain but i dunno even where to begin with that in this workers thing
  • s

    Serby

    04/30/2023, 3:46 AM
    like for example if i do cloudflare.mydomain.com the idea is that the users browser returns .. cloudflare.mydomain.com but that i can just capture the "cloudflare" or subdomain part and do something with it even if its just return it in the header
  • s

    Serby

    04/30/2023, 3:48 AM
    so I think that `*`/domain. com/`*` thing is the thing I need to do im just making sure that its even possible to allow that and I do that in the AAAA * 100:: proxied thing in the DNS tab ?
  • s

    Serby

    04/30/2023, 3:49 AM
    like im going to have it all redirect to the same html document i just need to capture whatever it is that is in the
    *
    and return it heh
  • c

    Chaika

    04/30/2023, 3:55 AM
    You can do that with Workers yea, just parse out the subdomain, a naive approach would be something like this:
    Copy code
    var url = new URL(request.url)
        var subdomain = url.host.split('.')[0]
    The you could just pass it in the header, or in the path/query/etc, whatever works with your origin
  • s

    Serby

    04/30/2023, 3:56 AM
    heh thats similar to what it looks like in my python so that makes sense to me okay but i dont have to do anything as far as the DNS settings thats where im getting hung up
  • c

    Chaika

    04/30/2023, 3:57 AM
    That's how you would set up a worker to run on wildcard subdomains yes
  • c

    Chaika

    04/30/2023, 3:57 AM
    In the DNS Tab, you add the record. The
    *.domain.com/*
    is a Worker Route, you would add that in the Worker Routes tab of your zone
  • s

    Serby

    04/30/2023, 3:57 AM
    okay
  • s

    Serby

    04/30/2023, 4:00 AM
    lol if I only had clicked this to begin with haha the placeholder in the addroute mentions it already
    *
    ..../`*`😅
  • s

    Serby

    04/30/2023, 4:05 AM
    thank you for helping me out I set it up ill mess with figuring out how to do what I need tomorrow now that I got this part setup thanks again
  • c

    Chaika

    04/30/2023, 4:10 AM
    Sure no problem, sorry if my instructions were a bit unclear, to clarify the
    AAAA * 100:: Proxied
    is the types/information of the DNS Record you need to create, AAAA being the type, * being the name,
    100::
    is the target.
    100::
    is IPv6 Discard, just used so that Cloudflare responds to DNS Queries with their Proxy IPs (allowing traffic to flow into Cloudflare's pipeline), and a worker route will handle the request before it actually tries to talk to a non-existent origin. The
    100::
    is just so even if it does fail to match a worker route, the traffic is just discarded rather then trying to talk to a real origin. You need a worker set up/created first before you create that worker route. You can configure Worker Routes either under the Worker's Trigger tab, or within a zone/website under the Worker Routes Tab (Magic Link: ). Before you add the wildcard route, make sure you have routes with Service: none for normal subdomains you do not want the worker to execute on. You can do that by just creating wildcard routes for them (
    coolsubdomain.example.com/*
    , Service: None). Otherwise, the wildcard worker would run on it Parsing out the subdomain is easy enough generally. For the other part, Workers can fetch a normal host, and you could just provide the subdomain in an http header.
  • s

    Serby

    04/30/2023, 4:13 AM
    I had a worked route but it was before I had pointed the domain name but when I went to the worker routes I was able to add the the
    *
    .domain. com/* and i saw that populated a drop down with None and the other test worker I had so I just linked it to that for now since that worker was already dishing my html template
  • s

    Serby

    04/30/2023, 4:17 AM
    yeah this is like a small project that is going to have 0 interaction with the server except to push a template then whatever the user enters is just going to check if whateverSubDomain exists somewhere else, I did see that they have web3 now on here so I might later on use that node to do the query ... thier is already a website that does what im trying to emulate the eth.xyz website if you look at that youll know what im trying to emulate
  • d

    Dani Foldi

    04/30/2023, 7:35 AM
    Answering in #909458221419356210 , please avoid posting in muliple channels
  • a

    AghaFarokh

    04/30/2023, 4:44 PM
    is there any good man to help me ? I'm so confused which type to chose for my worker type , Bundled or Unbound ? I'm using worker only for proxy which type is cheaper ?
  • a

    AghaFarokh

    04/30/2023, 4:44 PM
    Unbound requests 148.01M Billable duration 9.11M GB-sec Bundled requests 23.38M Durable Objects storage 0 B
  • a

    AghaFarokh

    04/30/2023, 4:45 PM
    this is my usage so far and it would be nice if someone help me to calculate the price 😄
  • h

    HardAtWork

    04/30/2023, 5:13 PM
    Assuming all of your requests fit within the CPU-time limit for Bundled, and the Billable duration is a representative sample of your total request duration, here is what each plan would cost, assuming you migrated all your requests to it:
  • u

    Unsmart | Tech debt

    04/30/2023, 5:34 PM
    I already answered this that you should use bundled 5 days ago 🤔 https://discord.com/channels/595317990191398933/779390076219686943/1100352854465712138
  • z

    Zakum

    04/30/2023, 6:59 PM
    Hi friends, I'm getting started with workers for the first time and want to set up a graphql api for a sveltekit project. The api is pretty big (60mb+ of jsons), what service should I use for this? Sounds like KV or D1 are the two more relevant options from the docs, but I'm not exactly sure on the differences/use cases for each. Could someone provide some beginner friendly advice? 🙏
  • s

    Skye

    04/30/2023, 7:11 PM
    Have you seen ?
  • z

    Zakum

    04/30/2023, 7:16 PM
    Yeah, but I don't really understand the implications to make a good decision
  • s

    Skye

    04/30/2023, 7:17 PM
    It depends on the kind of data you're storing, and what needs you have of it
  • z

    Zakum

    04/30/2023, 7:17 PM
    D1 looks too new to have many blog posts on it + graphql and such
  • s

    Skye

    04/30/2023, 7:17 PM
    If you share a little more of what you're trying to do, we can give some specific help
  • u

    Unsmart | Tech debt

    04/30/2023, 7:18 PM
    I mean with 60mb like you said in your first message only r2 can hold something that large without splitting the data across many keys 🤷
  • z

    Zakum

    04/30/2023, 7:22 PM
    I just want these jsons to be fetched and accessed inside the workers script, which would respond to POST requests (for gql purposes). All the data is static and doesn't need to be modified. I have a dummy up and running with the pokemon api but the issue is the size of the data I'm trying to use. My first thought was to use a VPS for the backend but I thought it would be a performance gain to use cloudflare's edge nodes (there will be a lot of international use)
1...242624272428...2509Latest