DiamondDragon
DiamondDragon
Explore posts from servers
CDCloudflare Developers
Created by DiamondDragon on 8/25/2024 in #pages-help
Error using API Create PagesProject with pulumi - Err 'You must set a production branch.'
Calling this from a monorepo. I want to use pulumi to create a pages project/update it
import { PagesProject, type PagesProjectArgs } from '@pulumi/cloudflare'

const projectName = 'spa-cf'
const CLOUDFLARE_ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID
const CLOUDFLARE_API_TOKEN = process.env.CLOUDFLARE_API_TOKEN

const pagesProjectConfig: PagesProjectArgs = {
accountId: CLOUDFLARE_ACCOUNT_ID,
name: projectName,
productionBranch: 'main',
buildConfig: {
buildCaching: true,
buildCommand: 'bun run build',
destinationDir: '../apps/spa/dist',
rootDir: '../apps/spa',
},
}

export const pagesProject = new PagesProject(projectName, pagesProjectConfig)

🚀 ~ file: pages.ts:58 ~ createProject ~ url: https://api.cloudflare.com/client/v4/accounts/xxxx/pages/projects
🚀 ~ file: pages.ts:58 ~ createProject ~ request: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer XXX'
},
body: '{"accountId":"XXXX","name":"spa-cf","productionBranch":"main","buildConfig":{"buildCaching":true,"buildCommand":"bun run build","destinationDir":"../apps/spa/dist","rootDir":"../apps/spa"}}'
import { PagesProject, type PagesProjectArgs } from '@pulumi/cloudflare'

const projectName = 'spa-cf'
const CLOUDFLARE_ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID
const CLOUDFLARE_API_TOKEN = process.env.CLOUDFLARE_API_TOKEN

const pagesProjectConfig: PagesProjectArgs = {
accountId: CLOUDFLARE_ACCOUNT_ID,
name: projectName,
productionBranch: 'main',
buildConfig: {
buildCaching: true,
buildCommand: 'bun run build',
destinationDir: '../apps/spa/dist',
rootDir: '../apps/spa',
},
}

export const pagesProject = new PagesProject(projectName, pagesProjectConfig)

🚀 ~ file: pages.ts:58 ~ createProject ~ url: https://api.cloudflare.com/client/v4/accounts/xxxx/pages/projects
🚀 ~ file: pages.ts:58 ~ createProject ~ request: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer XXX'
},
body: '{"accountId":"XXXX","name":"spa-cf","productionBranch":"main","buildConfig":{"buildCaching":true,"buildCommand":"bun run build","destinationDir":"../apps/spa/dist","rootDir":"../apps/spa"}}'
Initial deployment triggered: {
result: null,
success: false,
errors: [ { code: 8000033, message: 'You must set a production branch.' } ],
messages: []
}
Initial deployment triggered: {
result: null,
success: false,
errors: [ { code: 8000033, message: 'You must set a production branch.' } ],
messages: []
}
4 replies
CDCloudflare Developers
Created by DiamondDragon on 4/23/2024 in #pages-help
Can't deploy a nextjs pages site in subdirectory
No description
1 replies
CDCloudflare Developers
Created by DiamondDragon on 4/13/2024 in #workers-help
cron not running locally on the trigger specified
I'm using hono here but when i go to http://localhost:8787/__scheduled?cron=***** i see the response log
Hello
[wrangler:inf] GET /__scheduled 200 OK (11ms)
╭─────────────────────────────────────────────────────
Hello
[wrangler:inf] GET /__scheduled 200 OK (11ms)
╭─────────────────────────────────────────────────────
but I dont see anymore subsequent logs of the trigger again. am i doing anything wrong?
async function scheduledHandler(
event: ScheduledEvent,
env: Env,
ctx: ExecutionContext,
) {
const testMessages = [
'Hello',
'Goodbye',
'Welcome',
'Farewell',
'Greetings',
'I am leaving',
]
ctx.waitUntil(
(async () => {
const randomIndex = Math.floor(Math.random() * testMessages.length)
const randomMessage = testMessages[randomIndex]
console.log(randomMessage)
})(),
)
}

export default { fetch: app.fetch.bind(app), scheduled: scheduledHandler }
async function scheduledHandler(
event: ScheduledEvent,
env: Env,
ctx: ExecutionContext,
) {
const testMessages = [
'Hello',
'Goodbye',
'Welcome',
'Farewell',
'Greetings',
'I am leaving',
]
ctx.waitUntil(
(async () => {
const randomIndex = Math.floor(Math.random() * testMessages.length)
const randomMessage = testMessages[randomIndex]
console.log(randomMessage)
})(),
)
}

export default { fetch: app.fetch.bind(app), scheduled: scheduledHandler }
4 replies
CDCloudflare Developers
Created by DiamondDragon on 4/13/2024 in #pages-help
Project is set up for npm but it is currently being run via bun this might lead to build errors
Don't recall using npm when i init the repo but anyways, wondering what settings were set on npm that i should check out if im using bun
❯ nr
✔ script to run › preview
$ bun pages:build && wrangler pages dev .vercel/output/static
$ bunx @cloudflare/next-on-pages
⚡️ @cloudflare/next-on-pages CLI v.1.11.0

⚡️ The project is set up for npm but it is currently being run via bun this might lead to build errors, please be sure to use the same package manager your project uses when running @cloudflare/next-on-pages

⚡️ Detected Package Manager: bun (1.1.1)
⚡️ Preparing project...
⚡️ Project is ready
⚡️ Building project...
▲ Vercel CLI 34.0.0
WARNING: You should not upload the `.next` directory.
▲ Installing dependencies...
▲ removed 3 packages, and changed 96 packages in 18s

156 packages are looking for funding
▲ run `npm fund` for details
▲ Detected Next.js version: 14.2.0
▲ Detected `package-lock.json` generated by npm 7+
▲ Running "npm run build"
> next-cf@0.1.0 build
> next build
▲ ▲ Next.js 14.2.0
- Environments: .env.local
▲ Creating an optimized production build ...
▲ ✓ Compiled successfully
❯ nr
✔ script to run › preview
$ bun pages:build && wrangler pages dev .vercel/output/static
$ bunx @cloudflare/next-on-pages
⚡️ @cloudflare/next-on-pages CLI v.1.11.0

⚡️ The project is set up for npm but it is currently being run via bun this might lead to build errors, please be sure to use the same package manager your project uses when running @cloudflare/next-on-pages

⚡️ Detected Package Manager: bun (1.1.1)
⚡️ Preparing project...
⚡️ Project is ready
⚡️ Building project...
▲ Vercel CLI 34.0.0
WARNING: You should not upload the `.next` directory.
▲ Installing dependencies...
▲ removed 3 packages, and changed 96 packages in 18s

156 packages are looking for funding
▲ run `npm fund` for details
▲ Detected Next.js version: 14.2.0
▲ Detected `package-lock.json` generated by npm 7+
▲ Running "npm run build"
> next-cf@0.1.0 build
> next build
▲ ▲ Next.js 14.2.0
- Environments: .env.local
▲ Creating an optimized production build ...
▲ ✓ Compiled successfully
5 replies