Geometrically
Geometrically
Explore posts from servers
NNuxt
Created by Geometrically on 6/14/2024 in #❓・help
"Partially" pre-render page
Hello, I have a page in Nuxt which I would like to pre-render at build time. However, the header of my site changes based on whether a user is logged in or not. Is there a way for me to pre render the page only and not the template in Nuxt? Thank you!
6 replies
CDCloudflare Developers
Created by Geometrically on 11/6/2023 in #workers-help
Secrets in Cloudflare Workers
Hello, I am trying to upload secrets to my worker via GitHub Actions. However, it is not working. It says the secrets are uploaded but they aren't there. Do I need to put the secrets in my Wrangler.toml with dummy values so it registers? Repo: https://github.com/modrinth/sisyphus. This is my actions.yml. Everything works but secrets upload:
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.2
- name: Deploy app
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: deploy --env staging
secrets: |
LABRINTH_ADMIN_KEY
RATE_LIMIT_IGNORE_KEY
env:
LABRINTH_ADMIN_KEY: ${{ secrets.LABRINTH_ADMIN_SECRET_DEV }}
RATE_LIMIT_IGNORE_KEY: ${{ secrets.RATE_LIMIT_IGNORE_KEY_DEV }}
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.2
- name: Deploy app
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: deploy --env staging
secrets: |
LABRINTH_ADMIN_KEY
RATE_LIMIT_IGNORE_KEY
env:
LABRINTH_ADMIN_KEY: ${{ secrets.LABRINTH_ADMIN_SECRET_DEV }}
RATE_LIMIT_IGNORE_KEY: ${{ secrets.RATE_LIMIT_IGNORE_KEY_DEV }}
2 replies
CDCloudflare Developers
Created by Geometrically on 11/4/2023 in #workers-help
Should you use the cache API when requesting from R2?
I have a super simple worker wrapping R2. This is the code so far:
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
const key = url.pathname.slice(1);


const object = await env.MODRINTH_CDN.get(key);

if (object === null) {
return new Response(JSON.stringify({ error: 'not_found', description: 'the requested file does not exist' }), {
status: 404,
headers: {
'content-type': 'application/json',
},
});
}

const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set('etag', object.httpEtag);

return new Response(object.body, {
headers,
});
},
};
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
const key = url.pathname.slice(1);


const object = await env.MODRINTH_CDN.get(key);

if (object === null) {
return new Response(JSON.stringify({ error: 'not_found', description: 'the requested file does not exist' }), {
status: 404,
headers: {
'content-type': 'application/json',
},
});
}

const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set('etag', object.httpEtag);

return new Response(object.body, {
headers,
});
},
};
Do I have to use the Cache API to use the cloudflare CDN to cache the assets on R2? Or is that automatic. This cache API: https://developers.cloudflare.com/workers/examples/cache-api/. Or should I put a page rule in front of this saying to cache things
22 replies
CDCloudflare Developers
Created by Geometrically on 10/25/2023 in #general-help
Cannot Access Workers Dashboard
No description
4 replies
CDCloudflare Developers
Created by Geometrically on 7/4/2023 in #workers-help
Cannot set unbound function model: Workers
5 replies
CDCloudflare Developers
Created by Geometrically on 7/4/2023 in #general-help
WAF Blocking Calls from Cloudflare Workers
Hello, I have an API which is available on Cloudflare through https://api.modrinth.com. This API is protected by Cloudflare. I have a Cloudflare Pages website which calls this API via SSR. Right now, cloudflare seems to be blocking requests from my workers when it sends too many concurrently. How can I fix it? Thanks!
15 replies
CDCloudflare Developers
Created by Geometrically on 7/3/2023 in #workers-help
Nuxt + Markdown-it: Cannot convert object to primitive value
Hello, I am trying to use markdown-it in my application. It works fine on Nuxt and other serverless platforms like Vercel, but it does not work on Cloudflare Workers for some reason. Here is my code:
<template>
<div v-html="parsed">
</div>
</template>
<script setup>
import { ref } from 'vue'
import MarkdownIt from 'markdown-it'

const md = new MarkdownIt('default', {
html: true,
linkify: true,
breaks: false
})

const markdown = 'https://modrinth.com'

const parsed = ref(md.render(markdown))
</script>
<template>
<div v-html="parsed">
</div>
</template>
<script setup>
import { ref } from 'vue'
import MarkdownIt from 'markdown-it'

const md = new MarkdownIt('default', {
html: true,
linkify: true,
breaks: false
})

const markdown = 'https://modrinth.com'

const parsed = ref(md.render(markdown))
</script>
Here is a minimum repro example I have made: https://github.com/Geometrically/repro-nuxt-markdown. Let me know what I can do to fix this. The full error and calltrace is:
TypeError: Cannot convert object to primitive value
at Yc.format (core:user:repro-nuxi-markdown:19126:164)
at MarkdownIt$1.normalizeLink (core:user:repro-nuxi-markdown:20480:27)
at Array.Up (core:user:repro-nuxi-markdown:20146:377)
at ParserInline$1.tokenize (core:user:repro-nuxi-markdown:20315:48)
at ParserInline$1.parse (core:user:repro-nuxi-markdown:20326:17)
at Array.Kl (core:user:repro-nuxi-markdown:19540:57)
at Core.process (core:user:repro-nuxi-markdown:19586:15)
at MarkdownIt$1.parse (core:user:repro-nuxi-markdown:20536:24)
at MarkdownIt$1.render (core:user:repro-nuxi-markdown:20538:55)
at setup (core:user:repro-nuxi-markdown:20795:23) {
stack: TypeError: Cannot convert object to primitive valu…at setup (core:user:repro-nuxi-markdown:20795:23),
message: Cannot convert object to primitive value
}
TypeError: Cannot convert object to primitive value
at Yc.format (core:user:repro-nuxi-markdown:19126:164)
at MarkdownIt$1.normalizeLink (core:user:repro-nuxi-markdown:20480:27)
at Array.Up (core:user:repro-nuxi-markdown:20146:377)
at ParserInline$1.tokenize (core:user:repro-nuxi-markdown:20315:48)
at ParserInline$1.parse (core:user:repro-nuxi-markdown:20326:17)
at Array.Kl (core:user:repro-nuxi-markdown:19540:57)
at Core.process (core:user:repro-nuxi-markdown:19586:15)
at MarkdownIt$1.parse (core:user:repro-nuxi-markdown:20536:24)
at MarkdownIt$1.render (core:user:repro-nuxi-markdown:20538:55)
at setup (core:user:repro-nuxi-markdown:20795:23) {
stack: TypeError: Cannot convert object to primitive valu…at setup (core:user:repro-nuxi-markdown:20795:23),
message: Cannot convert object to primitive value
}
60 replies
CDCloudflare Developers
Created by Geometrically on 7/3/2023 in #workers-help
Favicon.ico not being found - Nuxt
24 replies
CDCloudflare Developers
Created by Geometrically on 6/2/2023 in #workers-help
R2 Domain Connection not working
I have an r2 bucket which the domain connection does not work. When I set the domain, it says initializing. When I reload hours later, it says "Unknown". When I go to the domain, https://launcher-files.modrinth.com/, it says CNAME Cross-user banned. This has not happened on any of my other existing buckets. I've tried recreating the bucket, reconnecting the domain, retrying the connection, and more, all to no avail. what should I do?
7 replies