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

    0xblackbird

    02/22/2023, 10:58 AM
    Thanks mate, got it, I found some other k8s clients as well but wanted to rely on the official one
  • u

    0xblackbird

    02/22/2023, 11:01 AM
    I will go with another solution for now, maybe I can switch later to cf workers once they fully replaced the deprecated request lib
  • s

    sathoro

    02/22/2023, 11:06 AM
    > Cannot create binding for class JWTCache that is not exported by the script > export { JWTCache } from "./JWTCache"; 😢
  • s

    sathoro

    02/22/2023, 11:09 AM
    I'm getting blocked from deploying with the above error, but I do have the export in my code like I have from my other DOs
  • s

    sathoro

    02/22/2023, 11:11 AM
    suddenly a new error > Cannot create binding for class JWTCache because it is not currently configured to implement > durable objects. Did you forget to apply a --new-class migration to it? never had to do this before hmm
  • s

    sathoro

    02/22/2023, 11:14 AM
    okay fixed with a new migration. didn't realize those were enforced. I wonder why it first said I hadn't exported the class
  • s

    sathoro

    02/22/2023, 11:16 AM
    I switched the KV to a DO and it is much better now. I'm just going to forget KV exists
  • t

    TheNinthSky

    02/22/2023, 12:52 PM
    It seems that there is a bug in the URL constructor.
    new URL('https://proxy.com/https://my-server.com').pathname
    returns
    /https:/my-server.com
    instead of
    /https://my-server.com
  • k

    kian

    02/22/2023, 12:53 PM
    What’s the compatibility date/flags for that Worker?
  • t

    TheNinthSky

    02/22/2023, 12:55 PM
    How can I check it out? I just created a new worker through the dashboard
  • k

    kian

    02/22/2023, 12:56 PM
    If you made it through Quick Edit then it will be a super old compatibility date
  • k

    kian

    02/22/2023, 12:56 PM
    You’d need to use Wrangler to set the compatibility date & publish it
  • t

    TheNinthSky

    02/22/2023, 12:58 PM
    I see. Will the compatibility date of 'Quick Edit' ever update?
  • s

    sathoro

    02/22/2023, 1:13 PM
    I think you can also set the node version as an environment variable too in the web UI, would that have the same effect?
  • s

    sathoro

    02/22/2023, 1:13 PM
    oh wait that is Pages isn't it
  • s

    Skye

    02/22/2023, 1:37 PM
    compat date is nothing to do with node version
  • s

    Skye

    02/22/2023, 1:37 PM
    but yes that's also pages
  • s

    sathoro

    02/22/2023, 2:59 PM
    random question... will this always be true for ipv6 addresses?
    request.headers.get("cf-connecting-ip").length === 39
  • p

    Plotzes

    02/22/2023, 3:00 PM
    probably not no, because you can have something like this:
    Copy code
    2744::3846
    but also
    Copy code
    4747:39f2:3847::4847
  • k

    kian

    02/22/2023, 3:01 PM
    yeah
  • h

    HardAtWork

    02/22/2023, 3:01 PM
    Or ::100
  • k

    kian

    02/22/2023, 3:01 PM
    2a06:98c0:3600::103
    is
    19
    chars for example
  • s

    sathoro

    02/22/2023, 3:03 PM
    hmmm
  • h

    HardAtWork

    02/22/2023, 3:04 PM
    Are you trying to detect IPv6 Addresses?
  • s

    sathoro

    02/22/2023, 3:04 PM
    yes just for rate limiting purposes I'm trying to get the /64 subnet of ipv6 addresses
  • s

    sathoro

    02/22/2023, 3:04 PM
    Copy code
    js
    export const getIPForRateLimiting = (request) => {
      let ip = request.headers.get("cf-connecting-ip");
    
      // is ipv6
      if (ip.length === 39) {
        // get the /64 section for rate limiting purposes
        return ip.substr(0, 19);
      }
    
      return ip;
    };
  • h

    HardAtWork

    02/22/2023, 3:05 PM
    No, I meant, are you trying to tell whether an IP Address in the header is IPV6?
  • h

    HardAtWork

    02/22/2023, 3:05 PM
    How about this?
    Copy code
    js
    export const getIPForRateLimiting = (request) => {
      let ip = request.headers.get("cf-connecting-ip");
    
      // is ipv6
      if (ip.includes(":")) {
        // get the /64 section for rate limiting purposes
        return ip.substr(0, 19);
      }
    
      return ip;
    };
  • h

    HardAtWork

    02/22/2023, 3:06 PM
    Oh wait
  • h

    HardAtWork

    02/22/2023, 3:06 PM
    The Substring...
1...229722982299...2509Latest