https://discord.cloudflare.com logo
Join Discord
Powered by
# pages-help
  • Next Js - Using binding in local development. Not working.
    s

    shakshuka

    05/06/2023, 6:28 PM
    This is how my terminal command looks: "npx wrangler pages dev --d1=NEXT_PUBLIC_DB --persist -- next dev" NEXT_PUBLIC_DB is the binding as created in the CF dashboard for preview and prod. When i try to access locally process.env.NEXT_PUBLIC_DB it is undefined. Accessing this binding after deploy works as described in docs but not local. Im using Next 13 and JS (not TS). I have tried to make the terminal command like so: "npx wrangler pages dev --d1=NEXT_PUBLIC_DB --binding NEXT_PUBLIC_DB=$NEXT_PUBLIC_DB --persist -- next dev" But still there was no change. Not working. PS: Some interesting stuff i found by trial and error (info not included in docs) is that if the binding in the dashboard is for eg. DB and not prefixed by "NEXT_PUBLIC_" it works in /api/[endpoint].js but not in pages. Post guidelines data to include: url: preview.freshfish.pages.dev deployment ID: a2074585-d3a5-4256-bc71-c11dccb0a860 account ID: db0a727799312b5edd59e905384cb9ac
    b
    • 2
    • 2
  • wasm imports not supported on server side.
    r

    RealJim

    05/07/2023, 10:22 AM
    when deploy pages application to cloudflare, wasm imports will throw error like this: 'ERROR: No loader is configured for ".wasm" files: ...@dqbd/tiktoken/tiktoken_bg.wasm.' here's my vite.config.js:
    Copy code
    export default defineConfig({
        plugins: [sveltekit(),wasm(),topLevelAwait()],
        build: {
              rollupOptions: {plugins: [wasm(),topLevelAwait()],},
        },
    }
    and the +page.server.js
    Copy code
    import { OpenAI } from "langchain/llms/openai";
    export async function load() {
      const model = new OpenAI();
      const res = await model.call("hello");
      return res;
    }
    what may be the problem?
  • Disable bot protection for pages
    p

    Pasukaru

    05/07/2023, 1:20 PM
    Can I disable bot protection for pages? My specific case is that Amethyst (Android App) is not able to access https://nostr.pasukaru.me/.well-known/nostr.json via TOR (using orbot). Without TOR it works. Accessing the page with a browser (also via TOR), I got the CF challenge. How can I disable that? On the domain level Bot Fight Mode is disabled. I also tried a Page Rule to Disable Security, no luck. Is there anything else? Thanks in advance. Account Id:
    d46bcbfb96be0041b72c7b1fc72a076f
    Pages.dev: https://6509bcfe.nip-5.pages.dev/ Deployment Id:
    6509bcfe-10f3-48a6-b6b4-1e92859922d0
    z
    c
    e
    • 4
    • 42
  • Slowdown in Pages Function Performance after Adding many Functions
    s

    shuyz

    05/07/2023, 3:39 PM
    I have been using one pages function, and it has been running smoothly with a median CPU time of 1.2ms. However, after adding many new functions, the median CPU time has increased to 18.8ms. I am certain that the new functions are not the ones causing this issue, as they have not been triggered in the logs. I am wondering how pages function handles multiple functions. I suspect that it merges them into a single JS file, which could explain why the more functions I add, the larger the JS file becomes, resulting in slower performance. After migrating the old function to a worker project, I found that the CPU usage was minimal, indicating that the function code itself is not the issue. Can anyone provide suggestions on how to optimize the performance with many functions?
    g
    t
    • 3
    • 7
  • fetch() calls throwing Connect Timeout Errors
    m

    Muhymin

    05/07/2023, 4:11 PM
    We are fetching a lof images from our CMS during build. We are recently getting
    Connect Timeout Error
    a lot. First, it was one image. But now the more images are getting added to the CMS, the more we are getting
    Connect Timeout Error
    . Why is it happening? Is there any concurrent request limit in Cloudflare Pages? And if there's a limit, should Cloudflare automatically handle this?
    z
    n
    j
    • 4
    • 21
  • Using smart placements with Pages
    n

    nish

    05/07/2023, 11:55 PM
    Is there a way to use Smart Placements with Pages at the moment? Our app would be making more than one call to our database and the increased latency makes edge workers a problem rather than an asset. I am able to resolve this with workers but not sure how to implement this with Pages. What would be even more ideal is being able to configure the placement based on a route. Example all requests to /server will be routed to this location, and all other routes can follow the regular edge model. Is this possible?
    j
    w
    • 3
    • 2
  • Segmentation fault on Gatsby Build
    n

    nicolasfry

    05/08/2023, 2:02 AM
    Hey all, I haven't had this happen yet and some of the search items are vague for how people solved this. I am getting seg faults when trying to deploy our app. I haven't been able to find my deployment ID. The error:
    Copy code
    21:46:22.183    AGsuccess Building production JavaScript and CSS bundles - 189.929s
    21:46:22.183    
    21:46:22.209    AGGatsby Config Mode: production
    21:46:22.210    
    21:46:42.421    /opt/build/bin/build: line 39:  1605 Segmentation fault      gatsby build
    21:46:42.483    Failed: build command exited with code: 139
    21:46:43.736    Failed: error occurred while running build command
    e
    • 2
    • 1
  • _redirects not working in CF Pages w/ functions on Nuxt 3 build
    m

    Matt Grah.am

    05/08/2023, 3:32 AM
    I have a redirects file setup in the build folder but when deployed (placing it in the public folder), the redirects do not work. Is there anything special I need to take into consideration with a Nuxt 3 build on CF Pages with functions?
    s
    • 2
    • 10
  • Github integration not detecting new commits?
    m

    markoan

    05/09/2023, 12:49 AM
    I noticed this a few minutes ago. Latest commits are not triggering a new deployment. Is this normal? I'm forcing them using custom hooks as a workaround. Is the integration broken? URL: genesys-messaging-widget.pages.dev ID would be: 1b0c771.genesys-messaging-widget.pages.dev Account: 709298ff49f7eb5c19071cf623daa13d
    w
    • 2
    • 2
  • Routing with workers
    s

    SmallShen

    05/09/2023, 3:26 AM
    I have a worker routes that listen to
    example.com/api/*
    ,
    example.com
    is hosted on pages. If I directly visit the api routes, it invoke the worker, but when I try to fetch
    /api/*
    endpoints in the page function, it will try to fetch from pages not workers. How do I solve this issue?
    • 1
    • 1
  • Pages behind Access
    m

    Msh

    05/09/2023, 7:55 AM
    How do you correctly places your pages deployment behind access? I have tried a few ways but it always returns odd results If you add access policy 3 times; one for *..pages.dev, another for .pages.dev, and another for the alias domain, if you try to access the alias domain, you first get the one time code then are redirected to login to the pages.dev application. If you assign the same access group to all 3 of the access applications, then it'll let you in but in the audit log you can see that it authenticates you against both the alias domain's access, followed by one of the pages.dev ones
    • 1
    • 3
  • Cloudflare is rebuilding node_modules in every build
    m

    Muhymin

    05/09/2023, 11:22 AM
    Cloudflare isn't caching the
    node_modules
    folder so that consequents build run faster. I see the message
    Started restoring cached node modules
    and
    Finished restoring cached node modules
    messages on the top of all the deployment logs. But it's not working actually.
    npm
    used to reinstall and download all the dependencies every time. Now, I am using
    pnpm
    , and the pnpm store is set to
    node_modules/.pnpm-store
    but it's redownloading and installing all the dependencies every time. I am also using
    astro-imagetools
    which stores its cache inside
    node_modules/.cache/astro-imagetools
    which is also not working. And it's heavily impacting the build time. I have tested both retrying deployments, adding a new commit, and triggering the deploy hooks. But none of them is able to restore the
    node_modules
    .
    h
    • 2
    • 13
  • uploading
    n

    new2discord

    05/09/2023, 12:36 PM
    Wrangler uploading take forever, while able to create project and login from WSL2.

    https://cdn.discordapp.com/attachments/1105473308436201493/1105473309363150889/image.png▾

  • robots.txt
    m

    mapple

    05/10/2023, 6:49 AM
    Hi - I'm moving a previous wordpress site to a static site using pages and a cloudflare custom domain. I've added a robots.txt file to the files uploaded - when I visit mysite.com/robots.txt or mysite.com/anystring it's showing the index page - how do I stop that behaviour - I'd rather the user/crawler was served a 404 for mysite.com/anystring than the home page?
    w
    • 2
    • 9
  • if I upload directly, is is it a build?
    c

    cog25

    05/10/2023, 1:53 PM
    If I upload files via Wrangler, does it count as a build?
    j
    h
    • 3
    • 3
  • nodejs_compat Compatability issue.
    t

    TetraEtc

    05/11/2023, 11:25 AM
    I'm trying to get nodejs compatability running using these instructions - https://developers.cloudflare.com/workers/platform/nodejs-compatibility/#enable-nodejs-from-the-cloudflare-dashboard From what I can see I've done this, screenshot attached. However, as per second screenshot, when the code is building it's still giving me the error about nodejs compatability.

    https://cdn.discordapp.com/attachments/1106180202708602911/1106180203207741511/image.png▾

    https://cdn.discordapp.com/attachments/1106180202708602911/1106180203522306148/image.png▾

    s
    • 2
    • 5
  • Middleware OK on `pages.dev`, not on custom domain?
    b

    BryceWray

    05/11/2023, 1:08 PM
    Am currently trying
    _middleware.js
    stuff for the first time with CF Pages, in an attempt to use it instead of an existing CF Worker. The middleware works perfectly on the
    pages.dev
    version — but, on the custom-domain version from that
    pages.dev
    , only the HTML files are affected even though it’s for all routes and files. To be more specific: on the
    pages.dev
    version, a number of custom headers (such as for caching) are added to a variety of file types, including CSS and image files; but, on the custom-domain version, this works for only the HTML files. Is there something special I have to do in the domain’s DNS, or elsewhere, to make the middleware work properly on the custom domain, too? (And I did remove the custom domain’s routes from the Worker for the test, so the Worker shouldn’t have been interfering.) The
    pages.dev
    domain = static-site-2to.pages.dev The custom domain = brycewray.com **Note**: I have had to re-add the custom domain routes to the Worker and take the
    _middleware.js
    file out of the project in order to regain the previous functionality, at least until I can learn why the middleware file doesn’t work on the custom domain. Let me know if you want me to restore the test setup.
    g
    • 2
    • 7
  • GitHub Actions not working
    a

    alexanderniebuhr

    05/11/2023, 7:18 PM
    Using
    pages-action
    or
    wrangler-action
    doe always lead to failed deployments. However using the cli works.
    Copy code
    pnpx wrangler pages publish apps/blog/dist --project-name=test
    * Anyone an Idea?*

    https://cdn.discordapp.com/attachments/1106299318744387715/1106299319029616690/Screenshot_2023-05-11_at_21.16.41.png▾

    https://cdn.discordapp.com/attachments/1106299318744387715/1106299319553888256/Screenshot_2023-05-11_at_21.17.28.png▾

    • 1
    • 1
  • required npm token is not working
    b

    bjornftw

    05/11/2023, 7:35 PM
    Trying to build my Vue 3 (vitejs) single app. Added an
    NODE_VERSION
    environment set to
    16.15.0
    . After deployment I see a
    npm ERR! Incorrect or missing password.
    error. I added my NPM token as
    NPM_TOKEN
    but not working. What to do

    https://cdn.discordapp.com/attachments/1106303463383638158/1106303463626903642/Screenshot_2023-05-11_at_21.34.11.png▾

    g
    • 2
    • 1
  • Vite deployment via git keeps failing build step, logs say `sh: 1: vite: not found`
    k

    kevinflo

    05/11/2023, 11:05 PM
    I tried multiple node versions, multiple framework presets, etc. Vite itself doesn't seem to be a framework preset option so I tried react and vue and none. I tried adding things to the build command. I followed the steps from the docs here https://developers.cloudflare.com/pages/framework-guides/deploy-a-vite3-project/ and here https://vitejs.dev/guide/static-deploy.html#cloudflare-pages Nothing I do seems to get it to have vite available during the build step. Am I missing something simple?
    c
    e
    • 3
    • 7
  • 500 Error for ~400 previously working Pages deployments
    b

    bigbhoooi

    05/12/2023, 4:56 AM
    Experiencing a strange issue on Cloudflare Pages: - 09:41pm UTC May 10: started seeing some intermittent downtime on our latest preview branch deployment (production deployment disabled) on one of our repos - 11:18pm UTC May 10: full downtime, never recovered. Note that, during this time period no deployments had been done anywhere close to the time frame. The error we get is a 500 error. I was thinking that there must be some issue with our code, but I reviewed through the deployment history (~475 deployments) and found that nearly all of them stopped working too. With only a small handful from a couple of months back that still worked. So over ~400 preview branch deployments all stopped working at the same time. This is accessing via the pages.dev domain, to ensure there wasn't some domain issue. But the custom domain showed the same. I've tried deleting the entire project and reconnecting it three times since and still get the same results. We're using Sveltekit. Does anyone know what could cause hundreds of previously working deployments to stop working at the same time? The front end has no dependency on the backend to 'work' (i.e. display correctly and not get a 500 error). Thank you.
    s
    • 2
    • 12
  • Having issues with generating a local kv
    b

    brettr91

    05/12/2023, 7:31 AM
    I'm having issues generating a local kv, it's with remix so I have added the --kv into the package.json wrangler script. > cross-env NODE_ENV=development npm run wrangler --kv sessionStorage > wrangler > wrangler pages dev ./public "sessionStorage" When I go to access the KV its undefined. const handleRequest = createPagesFunctionHandler({ build, mode: process.env.NODE_ENV, getLoadContext: (context) => { console.log("Session Storage"); console.log(context.env); const sessionStorage = createWorkersKVSessionStorage({ kv: context.env.sessionStorage, cookie: sessionCookie, }) return { ...context.env, sessionStorage } }, });
    h
    • 2
    • 3
  • Email Address Obfuscation
    c

    chrisgan

    05/12/2023, 2:04 PM
    I had enable the Email Address Obfuscation for the domain omorfizoi.gr. At this page(https://www.omorfizoi.gr/axizeis-agapi-kai-ochi-aporripsi), there is an email that appears as it was expected. At this page (https://www.omorfizoi.gr/event/diimero-retreat-exereyno-ton-eayto-moy-eimai-perissotera) there are some email addresses that appears as "email protected". In the inspector looks like added properly. Could you help me for fixing in? I disabled temporarily the Email Address Obfuscation through Cloudflare.

    https://cdn.discordapp.com/attachments/1106582730680045679/1106582730994626580/chrome_XCSfh1CjkU.png▾

    https://cdn.discordapp.com/attachments/1106582730680045679/1106582731334361130/msedge_Mr8eHsqWrC.png▾

    https://cdn.discordapp.com/attachments/1106582730680045679/1106582731854450759/chrome_7W3BGOztnz.png▾

    c
    • 2
    • 3
  • `This hostname is not covered by a certificate` only on pages CNAMES
    d

    DanTheGoodman

    05/12/2023, 10:13 PM
    See image:

    https://cdn.discordapp.com/attachments/1106705849298190446/1106705849415647365/image.png▾

    h
    c
    • 3
    • 70
  • Deploy a production vs preview build using GitHub Actions
    s

    ScarabCoder

    05/12/2023, 11:29 PM
    I have a GitHub action setup to build a React project, then deploy using this GitHub action: https://github.com/marketplace/actions/cloudflare-pages-github-action When it deploys, it's deploying it as a preview build. How do I get it to deploy as a production build instead? The docs seem to indicate that I can specify which branch is the production branch, but I've looked all over the Page settings in CF and don't see that option. It seems to be missing.
  • how to create ads.txt
    j

    Janno

    05/13/2023, 6:21 AM
    Like https://www.calculatorsoup.com/ads.txt anyone framework is svelte
    s
    • 2
    • 5
  • i cant login the login page is glitched
    r

    Rial

    05/13/2023, 10:51 AM
    Help me
  • My configured site does not work
    p

    Pedrex

    05/13/2023, 12:20 PM
    Hi, I bought https://pedrex.dev/ domain yesterday and I configured it to work with Cloudflare Pages, which is already working at https://pedrex-dev.pages.dev/ and custom domain is also configured, but it's just showing "Verifying", but the site itself just kept me on "DNS_PROBE_FINISHED_NXDOMAIN". How can I fix that? Thanks.
    s
    c
    • 3
    • 30
  • ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with ENOENT: node_modules/vite/bin/vite.js
    n

    narra

    05/13/2023, 2:15 PM
    I am using pnpm for my project. I already made the build command :
    npm install -g pnpm && pnpm i && pnpm build
    My environment is also using the following node version :
    NODE_VERSION 18.14.0
    • 1
    • 1
  • Issue with SCSS with Vite 4
    t

    TehZombiJesus

    05/14/2023, 1:44 PM
    Page:
    noximityweb.pages.dev
    Account ID:
    b068e1072ce66279dd2a98699d3ab816
    Log:
    Copy code
    Cloning repository...
    From https://github.com/NoximityMC/NoximityWeb
     * branch            dba2ef8dd157da87b84d1d49ddc3537705c57d4d -> FETCH_HEAD
    
    HEAD is now at dba2ef8 Initial commit
    
    
    Success: Finished cloning repository files
    Installing nodejs 18.16.0
    nodejs 18.16.0 is already installed
    Installing project dependencies: npm clean-install --progress=false
    
    added 364 packages, and audited 365 packages in 6s
    
    41 packages are looking for funding
      run `npm fund` for details
    08:55:50.261    
    08:55:50.261    found 0 vulnerabilities
    Executing user command: npm run build
    
    > base@0.0.0 build
    > tsc && vite build
    
    vite v4.3.5 building for production...
    transforming...
    ✓ 25 modules transformed.
    ✓ built in 750ms
    Could not resolve "../style/Navbar.scss" from "src/components/Navbar.tsx"
    file: /opt/buildhome/repo/src/components/Navbar.tsx
    error during build:
    RollupError: Could not resolve "../style/Navbar.scss" from "src/components/Navbar.tsx"
        at error (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:2125:30)
        at ModuleLoader.handleInvalidResolvedId (file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:23938:24)
        at file:///opt/buildhome/repo/node_modules/rollup/dist/es/shared/node-entry.js:23900:26
    Failed: Error while executing user command. Exited with error code: 1
    Failed: build command exited with code: 1
    Failed: error occurred while running build command
1...456...9Latest