https://discord.cloudflare.com logo
Join Discord
Powered by
# pages-help
  • Implementing Barcode scanning on my Webiste
    s

    spectralbyte

    01/05/2024, 5:30 PM
    Hey i tried implementing QuaggaJS and Instascan. Nothing worked out. Would be nice if someone could give me a hint. Or even better prov of concept code. LG TCT
  • Issues with functions routing with Nuxt.js
    n

    notjoemartinez

    01/05/2024, 8:20 PM
    So I've been building out an API on pages using functions by connecting a git repo with the following structure
    Copy code
    functions
    ├── ping.js
    └── index.js
    When I deploy it I can send a get request to
    mydomain.pages.dev/ping
    and it will respond with
    { "msg": "pong"}
    I want to deploy a Nuxt font end to this
    mydomain.pages.dev
    and have all the routes defined in my
    functions
    folder like
    /ping
    be considered API requests by the router. But when I deploy a Nuxt project with the
    functions
    folder included, Nuxt overrides all of the routes in
    folders
    and just redirects the page to
    /
    on Nuxt. The documentation on how to manage Nuxt routing with functions is pretty sparse https://developers.cloudflare.com/pages/framework-guides/deploy-a-nuxt-site/#use-bindings-in-your-nuxt-application
  • D1 binding + staticFormsPage
    d

    Dj_Laag [Michel]

    01/06/2024, 4:12 PM
    Hey all, i cannot figure out how to use the d1 binding along staticFormsPlugin. right now it doesnt even run the staticFormsPlugin Any ideas?
  • unable to launch cloudflare website gulp: not found
    m

    maybescripted

    01/07/2024, 1:28 AM
    heyo, insanely new to all of this and i just tried launching a portfolio website that i worked on (and plan on working on further later on) and i get the following right before it gives me the "Status: Failed" message: gulp: not found as far as my knowledge goes, i have everything gulp related installed, setup and correctly written down, i've double checked and tried looking stuff but i was unable to find an answer (i might be blind. idk) pages.dev: maybescripted.pages.dev deployment ID: ( it never deployed? / idk ) account ID: 3268abae632ef54b1353a002ca55781c the log error before it crashes is: Executing user command: gulp build /bin/sh: 1: gulp: not found Failed: Error while executing user command. Exited with error code: 127 Failed: build command exited with code: 1 Failed: error occurred while running build command . the full log is attached file. again i'm really sorry if this is something simple, or i'm not supposed to be asking questions like this here. i'm insanely new to this
    maybescripted-e86d0889-c224-4b03-972e-1d42b66fc628
  • Deployment errors on deploying nextjs site
    p

    priyanshu_gupta

    01/08/2024, 2:59 AM
    The site is working well with GitHub pages but having issues with cloudflare pages
    • 1
    • 1
  • Access bindings in dev
    b

    bdematt_47724

    01/08/2024, 12:12 PM
    I'm following this tutorial: https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/ And I've also tried the Qwik tutorial. I'm running the dev server using
    npm run pages:dev
    so using wrangler. In the case of Qwik, in the console I can see the message:
    Copy code
    Your worker has access to the following bindings:
    - D1 Databases:
      - DB: ...
    But the context is not provided to the request handler. In the case of Svelte,
    Copy code
    export async function post(context) {
      const env = context.platform.env // This is undefined
    }
    The [SvelteKit docs](https://kit.svelte.dev/docs/adapter-cloudflare) do say "platform.env is only available in the final build and not in dev mode." But I'm not sure how anyone is doing development without the bindings. Just build every time I want to test? Am I missing something? Anyone have any suggestions or workaround?
    • 1
    • 1
  • blog front-end fail
    o

    ogochukwu_aa

    01/08/2024, 4:54 PM
    Hi I was trying to learn how to use cloudflare and I tried to hop on the blog front-end tutorial but i keep getting this : Uncaught Error at o (history.ts:494:11) at Y (hooks.tsx:353:3) at ie (hooks.tsx:343:10) at Eo (react-dom.production.min.js:167:137) at Ei (react-dom.production.min.js:290:337) at ws (react-dom.production.min.js:280:389) at ys (react-dom.production.min.js:280:320) at gs (react-dom.production.min.js:280:180) at os (react-dom.production.min.js:271:88) at ls (react-dom.production.min.js:268:429) in the console of my browser after deployment. Could anyone explain this error because after deployment all I can see on the page is a white blank screen. Here is the link: https://0f169ff5.blogtrial.pages.dev/
  • Suspicious activity or security error in chrome after adding custom domain
    t

    tanjirokamado7975

    01/08/2024, 7:28 PM
    It was okay with penrage.pages.dev but when I added penrage.com custom domain the https://penrage.com/api/auth/signin shows suspicious activity why is that ??
    e
    • 2
    • 1
  • Cloudflare pages - 500 errors on accessing new deployments
    c

    crossvalidator

    01/08/2024, 8:17 PM
    Our new deployments are building but then throwing javascript errors when we try to access the deployed app. But we havent changed anything - code that was deploying correctly on Friday is suddenly throwing 500 errors. The error is about this “Cannot access ‘da’ before initialization\n at chunks/handlers/renderer.mjs:1:653972” - but nothing has changed in the code that would lead to this error. So I am confused. We have a nuxt 3 app deployed to Cloudflare Pages. The error seems to suggest that cloudflare is running into error when initializing our app - but we are redeploying code that hasnt changed - and it still fails - this seems weird. Any pointers would be greatly appreciated! Thanks.
  • Which object holds environment variables (Nuxt)
    c

    chronicstone

    01/09/2024, 7:20 PM
    I just configured & deployed a nuxt app to be deployed to cloudflare pages. Environment variables are all setup, but I can't seem to access them, like to setup my drizzle DB connexion : (I'm using
    t3-env
    to valdiate & access my env vars : https://env.t3.gg/)
    Copy code
    ts
    // db/index.ts
    import { neon, neonConfig } from '@neondatabase/serverless';
    import { drizzle as drizzleNeon } from 'drizzle-orm/neon-http';
    import * as schema from './schema';
    import { env } from '@/server/env';
    
    neonConfig.fetchConnectionCache = true;
    
    export const db = drizzleNeon(neon(env.DATABASE_URL), { schema, logger: false });
    Copy code
    ts
    // server/env.ts
    
    export const env = createEnv({
      server: {
        APP_BASE_URL: z.string().url(),
        APP_ENV: z.enum(['local', 'production']),
        DATABASE_URL: z.string().url(),
        DATABASE_SOURCE: z.enum(['neon', 'local']),
        CLERK_WEBHOOK_SECRET_KEY: z.string(),
        AWS_ACCESS_KEY_ID: z.string(),
        AWS_SECRET_ACCESS_KEY: z.string(),
        AWS_SES_REGION: z.string(),
        AWS_SES_SOURCE_EMAIL: z.string(),
        AWS_S3_REGION: z.string(),
        AWS_S3_BUCKET: z.string(),
        AWS_CLOUDFRONT_URL: z.string(),
        MAX_USER_PER_ORG: z.string().transform((v) => parseInt(v, 10)),
      },
    });
    All these env vars are alaways empty & validation fails. By default it looks into process.env, but I can change the lookup object. But I'm still not sure to understand how I can access these env vars. I tried looking into globalThis, process.env, import.meta.env but none of these objects seem to hold my env vars.
    k
    • 2
    • 1
  • Pages is installing bun 1.0.1
    s

    Skyfall

    01/10/2024, 9:58 PM
    The latest version is 1.0.21. This causes my build to fail. Account ID: b7624c46ee3377d0b12e2bf893c00685
    • 1
    • 1
  • nodejs_compat still not working as documented
    r

    Robin

    01/11/2024, 8:17 AM
    I added the nodejs_compat flag in the functions settings both envs, but builds still fail. The issue comes from authjs, which uses those node libraries. I really want to stay with cloudflare over vercel https://developers.cloudflare.com/workers/runtime-apis/nodejs/#enable-nodejs-from-the-cloudflare-dashboard suggests that those nodejs packages should work, yet they aren't. any help?
    Copy code
    > Using @sveltejs/adapter-cloudflare
    21:38:26.511    ✘ [ERROR] Could not resolve "crypto"
    21:38:26.512    
    21:38:26.512        .svelte-kit/output/server/chunks/hooks.server.js:4:26:
    21:38:26.513          4 │ import * as crypto$1 from "crypto";
    21:38:26.513            ╵                           ~~~~~~~~
    21:38:26.513    
    21:38:26.513      The package "crypto" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
    21:38:26.514    
    21:38:26.516    ✘ [ERROR] Could not resolve "node:buffer"
    21:38:26.517    
    21:38:26.517        .svelte-kit/output/server/chunks/hooks.server.js:6:23:
    21:38:26.517          6 │ import { Buffer } from "node:buffer";
    21:38:26.517            ╵                        ~~~~~~~~~~~~~
    21:38:26.517    
    21:38:26.517      The package "node:buffer" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
    21:38:26.517    
    
    ...
    
    21:38:26.532    error during build:
    21:38:26.532    Error: Build failed with 4 errors:
    21:38:26.532    .svelte-kit/output/server/chunks/hooks.server.js:4:26: ERROR: Could not resolve "crypto"
    21:38:26.532    .svelte-kit/output/server/chunks/hooks.server.js:6:23: ERROR: Could not resolve "node:buffer"
    21:38:26.532    .svelte-kit/output/server/chunks/hooks.server.js:7:26: ERROR: Could not resolve "node:crypto"
    21:38:26.532    .svelte-kit/output/server/chunks/hooks.server.js:9:22: ERROR: Could not resolve "node:util"
    k
    • 2
    • 1
  • Custom domain loads 3x slower than pages.dev subdomain
    h

    harshjv

    01/11/2024, 12:54 PM
    I've attached two HAR files for the following urls; 1. https://062d6d4f.etherbit-next-ui.pages.dev/ 2. https://www.etherbit.in/ As you can see, url #2 loads 3x slower than #1, even though the custom domain is pointing towards pages subdomain via CNAME with orange cloud enabled.
    www-etherbit-in062d6d4f-etherbit-next-ui-pages-dev
    • 1
    • 2
  • Deployment Failed for Pages app, can't find errors
    r

    rogerm_92112

    01/11/2024, 1:17 PM
    Hi, I have a Pages application that uses Functions with an AI binding. The project was created with C3 and is a Vue.js project. I successfully deployed the app to production three weeks ago, but today it keeps failing to deploy. It works ok in dev mode (
    npm run pages:dev
    ). I tried checking out the last successful deploy from git and installing the latest version of wrangler but it still not working. There are no errors in the console output when I run
    npm run pages:deploy
    it tells me it has successfully deployed. On the cloudflare dash the deployment has status "Failed" but I can't find where the error details are for the failed deployment. This is my main problem/concern - can Cloudflare Pages/Workers be troubleshooted efficiently? I tried commenting out my use of the AI binding but still same issue. Last attempted deployment was 2d46f548-8119-40a2-a911-fb80c08c5f32. Is it possible to see in the logs what is wrong?
    • 1
    • 1
  • Perform fetch request through proxy
    s

    samantas5855

    01/11/2024, 9:10 PM
    I have a VPS which is a proxy server and I would like to connect to it from Pages Functions. I'm looking for a way to perform a fetch request using my http proxy.
    c
    • 2
    • 1
  • Progressive Web App (PWA) in cloudflare pages is possible?
    b

    bernardosimonassi

    01/11/2024, 11:31 PM
    Hi guys, I'm trying to deploy a nuxt SPA with PWA in cloudflare pages but every article I find on the internet is relating PWA with cloudflare workers (not pages). I'm assuming that the only way to deploy a PWA is by using workers, this is weird because I can serve PWA apps with nginx with no server (only static files).
    • 1
    • 1
  • Could not reach Cloud Firestore backend.
    k

    kmoney4600

    01/12/2024, 1:54 AM
    I can't seem to get firestore to work. I have double checked that my secrets are all correct.
    Copy code
    js
    // /pages/api/players
    import { firestore } from "../../lib/firebase.js"
    import { collection, getDocs } from "firebase/firestore";
    export default async function handler() {
      const playerCollection = collection(firestore, 'players')
    
      try {
        const querySnapshot = await getDocs(playerCollection);
        const players = querySnapshot.docs.map(doc => doc.data())
        return Response.json(players)
      }
      catch(error) {
        console.error("Error fetching players:", error);
        return Response.error({ error: error.message });
      }
    }
    
    export const runtime = 'edge';
    Works locally and returns the players but on the deployed site I get the following
    Copy code
    "logs": [
        {
          "message": [
            "[2024-01-12T00:26:07.105Z]  @firebase/firestore:",
            "Firestore (10.7.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend."
          ],
          "level": "error",
          "timestamp": 1705019167105
        }
      ],
    Account id: af8655034e4604c85f195db49950778e Deployment id: 15bdd53b-16dc-4dc0-af06-5e9ec3e0fc11 Page: https://lack-leaderboards.pages.dev/
    • 1
    • 1
  • R2 Explorer keeps giving out TypeErrors
    c

    casperacy

    01/12/2024, 12:03 PM
    i'm using GitHub project called R2 Explorer (https://github.com/G4brym/R2-Explorer) which is a Google Drive like GUI for your R2. i ran the command
    npm create r2-explorer@latest
    in CMD, named my folder the same name as my R2, deployed it, and it keeps saying "**Waiting for deployment to become available**" in CMD. i ran the Real-time logs thing on the brand new Cloudflare worker it created, and it keeps spitting out a whole string. i'm not sure if i wanna share this string, cause it contains confidential information. but the message that stuck out to me was: { "name": "TypeError", "message": "o3.replace is not a function", "timestamp": 1705060569539 } if someone could help that would be greatly appreciated 😊
    c
    • 2
    • 2
  • Sveltekit on Cloudflare Pages Worker not working switching from Vercel
    s

    ssr0820

    01/12/2024, 5:34 PM
    I get strange error when i replace following in svelte.config.js: import adapter from '@sveltejs/adapter-vercel'; with import adapter from "@sveltejs/adapter-cloudflare";
    Copy code
    Run npm run preview to preview your production build locally.
    
    > Using @sveltejs/adapter-cloudflare
    ✘ [ERROR] Could not resolve "http"
    
        node_modules/.pnpm/nodemailer@6.9.8/node_modules/nodemailer/lib/fetch/index.js:3:21:
          3 │ const http = require('http');
            ╵                      ~~~~~~
    
      The package "http" wasn't found on the file system but is built into node. Are you trying to
      bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
    
    ✘ [ERROR] Could not resolve "events"
    
        node_modules/.pnpm/nodemailer@6.9.8/node_modules/nodemailer/lib/smtp-pool/index.js:3:29:
          3 │ const EventEmitter = require('events');
            ╵                              ~~~~~~~~
    message
  • version one, emacs installation error on cloudflare pages
    u

    0xhamzah

    01/12/2024, 10:17 PM
    I am having an issue with cloudflare not being able to use emacs to publish my org files this is my log
    • 1
    • 2
  • Making multiple applications with one repo
    r

    rudrecciah

    01/12/2024, 11:14 PM
    I'm using a monorepo for a project, and inside that monorepo are two different websites. I want to deploy both of them with Pages, but the dashboard only allows one application per repo. Is it possible to create multiple applications based on one repo somehow?
  • [Astro SSG] Why i am redirected after a form submit
    a

    amine.official

    01/13/2024, 1:03 PM
    Hello, When i submit my form i don't know why i am redirected to the
    MY_URL.com/api/submit
    page. I am using Astro (SSG) (V 3.3.4) with Pages (V 8.0.0) and Wrangler (V 3.22.4) What a want to do? - I want to create a simple form. When i submit the form my cloudflare pages function send me an email (with Resend.com api) What is the problem? - Everything is working, when i submit my form it send my an email but i don't want to be redirect from the
    MY_URL.com/contact
    to
    MY_URL.com/api/submit
    - I have this problem in dev (local) and in deployment I don't understand why i have this redirection (Step 2 in the screenshoot) My code:
    pages/contact.astro
    Copy code
    js
    ---
    import Layout from '../layouts/Layout.astro';
    ---
    
    <Layout title='Contact'>
      <form method="POST" action="/api/submit">
        <input type="text" name="name" pattern="[A-Za-z]+" required />
        <input type="email" name="email" required />
        <button type="submit">Submit</button>
      </form>
    </Layout>
    functions/api/submit.js
    Copy code
    js
    export async function onRequestPost(context) {
        return await submitHandler(context);
    }
    
    async function submitHandler(context) {
      const body = await context.request.formData();
      const { name, email} = Object.fromEntries(body);
    
      return fetch('https://api.resend.com/emails', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${RESEND_API_KEY}`,
        },
        body: JSON.stringify({
          from: `${MY_EMAIL}`,
          to: [`${email}`],
          subject: 'hello world',
          html: `${name}`,
        }),
      });
    }
    b
    • 2
    • 3
  • How CF Pages function get request.host referer
    n

    nodejava

    01/13/2024, 11:15 PM
    I have created a topic about How can I get request.host referer from CF Pages function https://community.cloudflare.com/t/how-cf-pages-function-get-request-host-referer/601736 I aim to identify the domain and the calling page URL, as there are multiple domains linking to this Page project. Utilizing these two parameters is essential for fetching distinct data based on the origin. I can see these two properties in the Real-time Logs of functions
    c
    • 2
    • 12
  • remix dev or remix build?
    l

    leavii

    01/14/2024, 6:04 AM
    I assume
    npm run dev
    , just the way they have it here is confusing for some one like myself that has 0 clue.
  • different behaviour with same deployments | 522 error on cloudflare pages
    a

    A. S.

    01/14/2024, 11:34 AM
    i've setup two cloudflare pages apps, and with exact same deployments (i've not touched settings in the dashboard), one of them gives error while other is working as it should. (redacted domain names, if possible i'd rather not share them publicly) any idea what might be wrong?
    Copy code
    bash
    $ cat www2/index.html
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
      </head>
      <body>
      </body>
    </html>
    
    $ wrangler pages deploy --project-name redacted5 www2
    🌍  Uploading... (1/1)
    
    ✨ Success! Uploaded 0 files (1 already uploaded) (0.53 sec)
    
    ✨ Deployment complete! Take a peek over at https://227df032.redacted5.pages.dev
    $ wrangler pages deploy --project-name redacted6 www2
    🌍  Uploading... (1/1)
    
    ✨ Success! Uploaded 0 files (1 already uploaded) (0.24 sec)
    
    ✨ Deployment complete! Take a peek over at https://e52e954d.redacted6.pages.dev
    $ curl https://redacted5.pages.dev
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
      </head>
      <body>
      </body>
    </html>
    
    $ curl https://redacted6.pages.dev
    error code: 522%
    $ cat www/_worker.js
    export default {
      /**
       * @param {Request} request
      */
      async fetch(request) {
        return new Response("hello to " + request.headers.get("User-Agent") || "N/A")
      },
    }
    $ wrangler pages deploy --project-name redacted6 www
    🌍  Uploading... (0/0)
    
    ✨ Success! Uploaded 0 files (0.19 sec)
    
    ✨ Compiled Worker successfully
    ✨ Uploading Worker bundle
    ✨ Deployment complete! Take a peek over at https://e83e374a.redacted6.pages.dev
    $ wrangler pages deploy --project-name redacted5 www
    🌍  Uploading... (0/0)
    
    ✨ Success! Uploaded 0 files (0.20 sec)
    
    ✨ Compiled Worker successfully
    ✨ Uploading Worker bundle
    ✨ Deployment complete! Take a peek over at https://be17aa6c.redacted5.pages.dev
    $ curl https://redacted6.pages.dev
    error code: 522%
    $ curl https://redacted5.pages.dev
    hello to curl/8.4.0%
    e
    h
    • 3
    • 7
  • _headers file issues
    p

    phenomenal_monkey_53911_38386

    01/14/2024, 10:23 PM
    Hi, I created a question here: https://community.cloudflare.com/t/cloudflare-pages-headers-file-does-not-work/602007 but the main question is: why is my
    _headers
    file not working when trying to set the
    Content-Encoding
    header? Thanks!
    • 1
    • 1
  • Page Rules for HTTP on specific subdomain causes TOO_MANY_REDIRECTS
    s

    sevenworks

    01/15/2024, 12:27 AM
    Whenever I setup cloudflare pages and then make a page rule that makes my cloudflare pages site http compatible when i use https on all my other stuff causes a
    TOO_MANY_REDIRECTS
    error. Does anyone know how to fix this so shop.sevenworks.eu.org is http and my other stuff is https? Thanks.
    • 1
    • 1
  • Website login-> google/oauth2 -> Error 524 (Host Error)
    r

    r3dh0t_sauce

    01/15/2024, 1:19 AM
    Hello I need some clarification regarding this error, my website is working fine before, but just last fridat it seems it will took too long to received or response to the google auth when i try to login my gmail account. I already contacted the hosting provider but there is no problem on there side, i also tried to login on the non-proxied website it can login with no problem but on the proxied site it loads very long after that it shows Error 524. Thank you
  • Deploying Jekyll site Error
    l

    lensy7356

    01/15/2024, 1:40 AM
    Hi I'm trying to deploy a jekyll website in cloudflare pages but I'm getting this error. I already set the environmental variables: ==== Build settings ==== Build command: jekyll build Build output directory: /_site Build system version: 2 (latest) Root directory: / Environment variables: Variable name Value RUBY_VERSION 2.7.3 ==== Error when deploying ==== 09:10:21.401 Executing user command: jekyll build 09:10:21.818 No preset version installed for command jekyll 09:10:21.818 Please install a version by running one of the following: 09:10:21.818 09:10:21.818 asdf install ruby 2.7.3 09:10:21.819 09:10:21.819 or add one of the following versions in your config file at /opt/buildhome/.tool-versions 09:10:21.828 ruby 3.2.2 09:10:21.830 Failed: Error while executing user command. Exited with error code: 126 09:10:21.844 Failed: build command exited with code: 1 09:10:22.800 Failed: error occurred while running build command
  • A large number of internal transitions
    y

    y4utejib

    01/15/2024, 10:08 AM
    How do I set up the correct referral when redirecting from pages ?__cf_chl_tk= At the moment, such transitions are considered internal, but it is necessary that it be a transition from search engines