Spunkie
Spunkie
Explore posts from servers
NNuxt
Created by Spunkie on 9/20/2024 in #❓・help
Where do I place CF workers/functions?
I have a statically generated, content driven, nuxt3 site that is deployed on CF pages through the github integration. Where an I supposed to be placing my workers/functions in my nuxt file structure so it eventually gets compiled to where it should be when generated? So CF pages automatically picks them up and deploys them as CF workers/functions?
4 replies
NNuxt
Created by Spunkie on 7/19/2024 in #❓・help
Comprehensive list of native front-matter meta tags?
The docs(https://content.nuxt.com/usage/markdown#front-matter) say that title, description, draft, navigation, and head are the only native parameters for front-matter. But if I put an image tag into my front-matter content files like this
---
title: 'Tester'
description: 'It's a test.'
image: '/images/tester.png'
---
---
title: 'Tester'
description: 'It's a test.'
image: '/images/tester.png'
---
nuxt does render it properly into a og:image meta tag:
<head>
<title>Tester</title>
<meta property="og:title" content="Tester" />
<meta name="description" content="It's a test." />
<meta property="og:description" content="It's a test." />
<meta property="og:image" content="/images/tester.png" />
</head>
<head>
<title>Tester</title>
<meta property="og:title" content="Tester" />
<meta name="description" content="It's a test." />
<meta property="og:description" content="It's a test." />
<meta property="og:image" content="/images/tester.png" />
</head>
So where can I find an actual comprehensive list of native front-matter parameters?
1 replies
NNuxt
Created by Spunkie on 3/16/2024 in #❓・help
404 status when displaying `Document is empty` message?
I have a static and content/document driven nuxt 3 blog. It has some placeholder markdown files under /content/ that just have their front-matter filled out. For example:
/content/4.tester/index.md
---
title: 'Example Title'
description: 'Example Desc'
navigation:
title: 'Resources'
bg: 'white'
---
/content/4.tester/index.md
---
title: 'Example Title'
description: 'Example Desc'
navigation:
title: 'Resources'
bg: 'white'
---
When I go to to the above example, example.com/tester, it displays this error/msg but still returns a 200 status code.
Document is empty

Add content to it by opening content/4.tester/index.md file.
Document is empty

Add content to it by opening content/4.tester/index.md file.
How can I get nuxt to return a 404 status code whenever this Document is empty error/msg shows up?
1 replies
CDCloudflare Developers
Created by Spunkie on 12/14/2023 in #pages-help
Nuxt `npx nuxi generate` sometimes builds to `.output/public` and other times to `.dist`?
I'm using the latest nuxt on cloudflare pages but my builds are failing sometimes because of the differing output dir. I don't really understand what is causing the difference in behavior. I'm following the nuxt docs on deployment so on CF pages I'm running npx nuxi generate and looking for the build dir of .output/public. I've also tried with node 16 and 18 but it doesn't fix the issue. Some branches are building, while others are not on CF. If I clone the branches with failed builds and run npx nuxi generate locally it builds to the correct .output/public dir. CF pages:
21:22:06.570 Executing user command: npx nuxi generate
21:22:08.238 [log] Nuxt 3.8.2 with Nitro 2.8.1
21:22:08.554 [info] Using Nitro server preset: `static`
...
21:22:37.971 [success] [nitro] Generated public dist
21:22:38.013 [success] [nitro] You can preview this build using `npx wrangler pages dev dist`
21:22:38.014 [success] [nitro] You can deploy this build using `npx wrangler pages deploy dist`
21:22:38.014 [success] You can now deploy `dist` to any static hosting!
21:22:38.195 Finished
21:22:38.196 Note: No functions dir at /functions found. Skipping.
21:22:38.196 Validating asset output directory
21:22:38.196 Error: Output directory ".output/public" not found.
21:22:39.508 Failed: build output directory not found
21:22:06.570 Executing user command: npx nuxi generate
21:22:08.238 [log] Nuxt 3.8.2 with Nitro 2.8.1
21:22:08.554 [info] Using Nitro server preset: `static`
...
21:22:37.971 [success] [nitro] Generated public dist
21:22:38.013 [success] [nitro] You can preview this build using `npx wrangler pages dev dist`
21:22:38.014 [success] [nitro] You can deploy this build using `npx wrangler pages deploy dist`
21:22:38.014 [success] You can now deploy `dist` to any static hosting!
21:22:38.195 Finished
21:22:38.196 Note: No functions dir at /functions found. Skipping.
21:22:38.196 Validating asset output directory
21:22:38.196 Error: Output directory ".output/public" not found.
21:22:39.508 Failed: build output directory not found
Building same commit locally:
npx nuxi generate
Nuxt 3.8.2 with Nitro 2.8.1
ℹ Using Nitro server preset: static
ℹ Building client...
...
✔ Generated public .output/public
✔ You can preview this build using npx serve .output/public
✔ You can now deploy .output/public to any static hosting!
npx nuxi generate
Nuxt 3.8.2 with Nitro 2.8.1
ℹ Using Nitro server preset: static
ℹ Building client...
...
✔ Generated public .output/public
✔ You can preview this build using npx serve .output/public
✔ You can now deploy .output/public to any static hosting!
ref: https://nuxt.com/docs/getting-started/deployment#crawl-based-pre-rendering
2 replies
NNuxt
Created by Spunkie on 12/14/2023 in #❓・help
`npx nuxi generate` sometimes builds to .output/public and other times to .dist?
I'm using the latest nuxt on cloudflare pages but my builds are failing sometimes because of the differing output dir. I don't really understand what is causing the difference in behavior. I'm following the nuxt docs on deployment so on CF pages I'm running npx nuxi generate and looking for the build dir of .output/public. I've also tried with node 16 and 18 but it doesn't fix the issue. Some branches are building, while others are not on CF. If I clone the branches with failed builds and run npx nuxi generate locally it builds to the correct .output/public dir. CF pages:
21:22:06.570 Executing user command: npx nuxi generate
21:22:08.238 [log] Nuxt 3.8.2 with Nitro 2.8.1
21:22:08.554 [info] Using Nitro server preset: `static`
...
21:22:37.971 [success] [nitro] Generated public dist
21:22:38.013 [success] [nitro] You can preview this build using `npx wrangler pages dev dist`
21:22:38.014 [success] [nitro] You can deploy this build using `npx wrangler pages deploy dist`
21:22:38.014 [success] You can now deploy `dist` to any static hosting!
21:22:38.195 Finished
21:22:38.196 Note: No functions dir at /functions found. Skipping.
21:22:38.196 Validating asset output directory
21:22:38.196 Error: Output directory ".output/public" not found.
21:22:39.508 Failed: build output directory not found
21:22:06.570 Executing user command: npx nuxi generate
21:22:08.238 [log] Nuxt 3.8.2 with Nitro 2.8.1
21:22:08.554 [info] Using Nitro server preset: `static`
...
21:22:37.971 [success] [nitro] Generated public dist
21:22:38.013 [success] [nitro] You can preview this build using `npx wrangler pages dev dist`
21:22:38.014 [success] [nitro] You can deploy this build using `npx wrangler pages deploy dist`
21:22:38.014 [success] You can now deploy `dist` to any static hosting!
21:22:38.195 Finished
21:22:38.196 Note: No functions dir at /functions found. Skipping.
21:22:38.196 Validating asset output directory
21:22:38.196 Error: Output directory ".output/public" not found.
21:22:39.508 Failed: build output directory not found
Building same commit locally:
npx nuxi generate
Nuxt 3.8.2 with Nitro 2.8.1
ℹ Using Nitro server preset: static
ℹ Building client...
...
✔ Generated public .output/public
✔ You can preview this build using npx serve .output/public
✔ You can now deploy .output/public to any static hosting!
npx nuxi generate
Nuxt 3.8.2 with Nitro 2.8.1
ℹ Using Nitro server preset: static
ℹ Building client...
...
✔ Generated public .output/public
✔ You can preview this build using npx serve .output/public
✔ You can now deploy .output/public to any static hosting!
2 replies
CDCloudflare Developers
Created by Spunkie on 2/14/2023 in #workers-help
Page breaks when fetched/returned by worker
I have this public share link: https://view.monday.com/3776000595-36cfd13f4d0b049a330a3952bdae0ff9 and this bit of worker code I copied from the examples:
export default {
async fetch(request) {
const url = 'https://view.monday.com/3776000595-36cfd13f4d0b049a330a3952bdae0ff9';

async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get('content-type') || '';
if (contentType.includes('application/json')) {
return JSON.stringify(await response.json());
} else if (contentType.includes('application/text')) {
return response.text();
} else if (contentType.includes('text/html')) {
return response.text();
} else {
return response.text();
}
}

const init = {
headers: {
'content-type': 'text/html;charset=UTF-8',
},
};

const response = await fetch(url, request);
const results = await gatherResponse(response);
return new Response(results, init);
},
};
export default {
async fetch(request) {
const url = 'https://view.monday.com/3776000595-36cfd13f4d0b049a330a3952bdae0ff9';

async function gatherResponse(response) {
const { headers } = response;
const contentType = headers.get('content-type') || '';
if (contentType.includes('application/json')) {
return JSON.stringify(await response.json());
} else if (contentType.includes('application/text')) {
return response.text();
} else if (contentType.includes('text/html')) {
return response.text();
} else {
return response.text();
}
}

const init = {
headers: {
'content-type': 'text/html;charset=UTF-8',
},
};

const response = await fetch(url, request);
const results = await gatherResponse(response);
return new Response(results, init);
},
};
If I go directly to the link in my browser the page loads like I expect but if I instead fetch the same page with a worker and return it, then the page is broken. Anyone have any idea what I can do to get this page working?
23 replies
CDCloudflare Developers
Created by Spunkie on 2/9/2023 in #workers-help
Can I edit html of an iframe if I CNAME it?
I have an embedded iframe from a domain I don't control and I need to replace a link in the iframes content with another link. Is this something I can do with a CNAME cloudflare to the iframe + a CF worker?
7 replies