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

    Cyb3r-Jok3

    04/01/2023, 2:32 AM
    Tunnel is going to be easiest
  • c

    chientrm

    04/01/2023, 2:42 AM
    I added a tunnel using my custom domain
  • c

    chientrm

    04/01/2023, 2:42 AM
    but when I access the api with that domain.
  • c

    chientrm

    04/01/2023, 2:42 AM
    the
    req.url
    is
    https://worker.*.workers.dev
  • c

    chientrm

    04/01/2023, 2:43 AM
    not my custom domain.
  • c

    Cyb3r-Jok3

    04/01/2023, 2:44 AM
    Oh sorry didn't realize you were using the url. Not sure if you change that, given the way that dev works. Maybe try local mode with the tunnel
  • c

    chientrm

    04/01/2023, 2:44 AM
    because I need to
    fetch
    from my worker to an another service on the same root domain.
  • c

    chientrm

    04/01/2023, 2:45 AM
    and that service cors is off.
  • c

    Cyb3r-Jok3

    04/01/2023, 2:45 AM
    Are you not using service bindings?
  • c

    chientrm

    04/01/2023, 2:45 AM
    oops
  • c

    chientrm

    04/01/2023, 2:46 AM
    the other service's running with NodeJS. will it work?
  • c

    Cyb3r-Jok3

    04/01/2023, 2:46 AM
    Ah nope that won't work service bindings only work between workers. Hopefully someone else has an idea on how to get it working
  • c

    chientrm

    04/01/2023, 2:47 AM
    so, my core api's running on a vps. my outer-layer api runs on worker.
  • c

    chientrm

    04/01/2023, 2:47 AM
    I found this guide: https://github.com/brettscott/cloudflare-worker-tunnel-mysql-example
  • c

    chientrm

    04/01/2023, 2:50 AM
    I do this but the
    res
    turn the application login page 😐
  • c

    chientrm

    04/01/2023, 2:50 AM
    any chance it's about cors?
  • c

    Cyb3r-Jok3

    04/01/2023, 2:57 AM
    Is the worker running on the same domain as an access policy?
  • c

    chientrm

    04/01/2023, 2:57 AM
    yes they are
  • c

    Cyb3r-Jok3

    04/01/2023, 2:58 AM
    Access polices are before workers so you'd need to make the worker call a different subdomain that is protected by access
  • c

    chientrm

    04/01/2023, 3:01 AM
    I solved it.
  • c

    chientrm

    04/01/2023, 3:02 AM
    it's about policy type.
  • c

    chientrm

    04/01/2023, 3:02 AM
    when create application policy, there's a combobox to select
    Policy Type
    , I change it to
    Service Token
    and choose the service token I created. Now it work as intended.
  • c

    chientrm

    04/01/2023, 3:03 AM
    By default, policy type is
    Allow
    .
  • c

    chientrm

    04/01/2023, 3:03 AM
    It even works when I browse worker using
    localhost
    .
  • c

    chientrm

    04/01/2023, 3:42 AM
    One more thing. When piping stream output from external service -> worker -> client, the streaming pipe can last up to minutes. Does it count toward worker runtime limit? šŸ¤”
  • k

    kian

    04/01/2023, 3:54 AM
    Depends if the Worker is generating the output or if it’s from another service like KV/R2 or a fetch subrequest
  • c

    chientrm

    04/01/2023, 3:55 AM
    the other fetch subrequest generate output, worker doesn't interfere with the output.
  • k

    kian

    04/01/2023, 3:56 AM
    As long as it’s returned as-is and the body isn’t being transformed, the Workers can be evicted and so once the headers are sent (and you’re not doing any waitUntil work) the limits stop counting as that Worker invocation is gone
  • k

    kian

    04/01/2023, 4:03 AM
    https://blog.cloudflare.com/workers-optimization-reduces-your-bill/
  • c

    chientrm

    04/01/2023, 4:07 AM
    tysm
1...237323742375...2509Latest