spectralbyte
01/05/2024, 5:30 PMnotjoemartinez
01/05/2024, 8:20 PMfunctions
├── 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-applicationDj_Laag [Michel]
01/06/2024, 4:12 PMmaybescripted
01/07/2024, 1:28 AMpriyanshu_gupta
01/08/2024, 2:59 AMbdematt_47724
01/08/2024, 12:12 PMnpm run pages:dev
so using wrangler. In the case of Qwik, in the console I can see the message:
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,
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?ogochukwu_aa
01/08/2024, 4:54 PMtanjirokamado7975
01/08/2024, 7:28 PMcrossvalidator
01/08/2024, 8:17 PMchronicstone
01/09/2024, 7:20 PMt3-env
to valdiate & access my env vars : https://env.t3.gg/)
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 });
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.Skyfall
01/10/2024, 9:58 PMRobin
01/11/2024, 8:17 AM> 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"
harshjv
01/11/2024, 12:54 PMrogerm_92112
01/11/2024, 1:17 PMnpm 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?samantas5855
01/11/2024, 9:10 PMbernardosimonassi
01/11/2024, 11:31 PMkmoney4600
01/12/2024, 1:54 AMjs
// /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
"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/casperacy
01/12/2024, 12:03 PMnpm 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 😊ssr0820
01/12/2024, 5:34 PMRun 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');
╵ ~~~~~~~~
0xhamzah
01/12/2024, 10:17 PMrudrecciah
01/12/2024, 11:14 PMamine.official
01/13/2024, 1:03 PMMY_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
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
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}`,
}),
});
}
nodejava
01/13/2024, 11:15 PMleavii
01/14/2024, 6:04 AMnpm run dev
, just the way they have it here is confusing for some one like myself that has 0 clue.A. S.
01/14/2024, 11:34 AMbash
$ 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%
phenomenal_monkey_53911_38386
01/14/2024, 10:23 PM_headers
file not working when trying to set the Content-Encoding
header? Thanks!sevenworks
01/15/2024, 12:27 AMTOO_MANY_REDIRECTS
error. Does anyone know how to fix this so shop.sevenworks.eu.org is http and my other stuff is https? Thanks.r3dh0t_sauce
01/15/2024, 1:19 AMlensy7356
01/15/2024, 1:40 AMy4utejib
01/15/2024, 10:08 AM