https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • t

    TetraEtc

    02/18/2023, 10:16 AM
    Ok, do you have any good resources regarding this?
  • s

    Skye

    02/18/2023, 10:19 AM
    Looking at the docs for it.. but they're not very well organized
  • s

    Skye

    02/18/2023, 10:20 AM
    ah here it is https://nuxt.com/docs/guide/directory-structure/server
  • t

    TetraEtc

    02/18/2023, 10:22 AM
    Ok, so instead of using
    /functions
    in my repo, I should switch to
    /server/routes
    ?
  • s

    Skye

    02/18/2023, 10:23 AM
    If you want any ssr/dynamic functionality for your site, using that will be much easier
  • s

    Skye

    02/18/2023, 10:24 AM
    but if your site is static, you may find it easier to just use functions directly and tell nuxt to not generate any for you
  • t

    TetraEtc

    02/18/2023, 10:28 AM
    Ok cool, that's something I'll have to play with more - never really looked at the server stuff for nuxt
  • t

    TetraEtc

    02/18/2023, 10:28 AM
    lookslike it makes it easier to do dev locally too
  • t

    TetraEtc

    02/18/2023, 10:36 AM
    Hmm, still getting
    ✘ [ERROR] No routes found when building Functions directory: /opt/buildhome/repo/functions
  • s

    Skye

    02/18/2023, 10:43 AM
    Did you remember to remove the old functions folder?
  • t

    TL&D

    02/19/2023, 4:39 AM
    I have experimented with several projects, and the services distributed by cloudflare pages functions are always behind in Google search with the same keyword. In addition, even if you provide a site map normally, if you distribute it as cloudflare pages, you often get error conditions that look normal when you access it directly, but Google Bot cannot read. What do you think of the two problems above?
  • a

    Acе

    02/19/2023, 6:20 PM
    So does pages run off nuxt?
  • h

    HardAtWork

    02/19/2023, 6:20 PM
    No, Pages runs on https://workers.cloudflare.com
  • b

    Biey

    02/20/2023, 12:52 PM
    Hi, Is there any way to inject ENV besides manually on cloudflare dashboard
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2023, 3:06 PM
    Not presently.
  • b

    Biey

    02/20/2023, 3:06 PM
    I'm able to inject env vars through api
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2023, 3:08 PM
    Oh, yeah, sorry, ofc 🙂 Most people only consider dash and wrangler. But yes, we do support setting those environment variables and bindings with the API as well 🙂
  • b

    Biey

    02/20/2023, 3:10 PM
    Yes thanks. Hopefully this can be done through wrangler so we can easily make manage it on devops end. wrangler.toml or cli command
  • j

    jgarr

    02/21/2023, 6:34 AM
    Where can I see logs for page functions? I found execution metrics but having a hard time debugging things without logs. using console.log() in the function isn't writing to my browser console either (not sure why)
  • j

    jgarr

    02/21/2023, 6:56 AM
    oh, it looks like
    wrangler pages deployment --environment preview tail
    will work
  • s

    Skye

    02/21/2023, 7:31 AM
    > using console.log() in the function isn't writing to my browser console either (not sure why) This is because your functions are running server side - not in your browser
  • j

    jgarr

    02/21/2023, 7:31 AM
    Yep, seeing the output in the wrangler output logs
  • s

    Skye

    02/21/2023, 7:33 AM
    Just thought I'd explain 🙂
  • s

    sdev

    02/21/2023, 4:34 PM
    Does functions support WebStreams APIs?
  • k

    kian

    02/21/2023, 4:35 PM
    https://developer.mozilla.org/en-US/docs/Web/API/Streams_API these? If so, yes
  • s

    sdev

    02/21/2023, 4:44 PM
    I can use
    defer
    to send body with
    renderToReadableStream
    in Workers. However, after I migrate the remix app to Pages, it throws error for using
    defer
    response.
  • s

    sdev

    02/21/2023, 4:44 PM
    Not sure it is because of functions bug or remix defer bug.
  • s

    sdev

    02/21/2023, 4:44 PM
    However it works fine with Workers app.
  • s

    Skye

    02/21/2023, 4:45 PM
    Could you share the specific error?
  • s

    sdev

    02/21/2023, 5:54 PM
    Copy code
    ts
    // app/entry.server.tsx
    export default async function handleRequest(
      request: Request,
      responseStatusCode: number,
      responseHeaders: Headers,
      remixContext: EntryContext
    ) {
      const body = await renderToReadableStream(
        <RemixServer context={remixContext} url={request.url} />,
        {
          onError(error) {
            console.error("renderToReadableStream error"); // Error thrown from here
            console.error(error);
            responseStatusCode = 500;
          },
          signal: request.signal,
        }
      );
    
      if (isbot(request.headers.get("User-Agent"))) {
        await body.allReady; // https://beta.reactjs.org/reference/react-dom/server/renderToReadableStream#returns
      }
    
      const headers = new Headers(responseHeaders);
      headers.set("Content-Type", "text/html");
    
      return new Response(body, {
        status: responseStatusCode,
        headers,
      });
    }
    There is no specific error about wrangler. It just returns
    undefined
    value instead of resolved to the real data in React
    Await
    component.
1...347348349...392Latest