LTroya
04/18/2023, 9:35 PMnate!
04/19/2023, 3:52 AMO Rato
04/19/2023, 4:24 AMsemistrict
04/19/2023, 5:17 AM/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
runtime: "edge"
}
module.exports = nextConfig
Not sure what else to try here.jdkdev
04/19/2023, 3:36 PMMagnusIntergiro
04/19/2023, 7:25 PMNPM_AUTH_TOKEN
in my .bashrc
.
And the registry is set in .npmrc
in the repo, so that should be fine.
But I don't know where to add the NPM_AUTH_TOKEN
for the cf-pages to install and build?sizumita
04/20/2023, 2:36 AMnpx @cloudflare/next-on-pages --experimental-minify
and CLOUDFLARE_ACCOUNT_ID=xxx npx wrangler pages publish .vercel/output/static --project-name yyy
but it causes deploy error (failed) without any error text.
account id: 145418bdc7871190e993bb8083b0c02c
deploy id: None
Grentenville
04/20/2023, 12:56 PMEvil Morty
04/21/2023, 12:17 AMAllanGalera
04/21/2023, 6:22 AMgot
it works fine locally but when I deploy I get that it needs nodejs_compat
. I tried adding in the UI at settings > function > compatibility flags but didn't work.
When I use fetch it fails locally with a fetch failed
with something about a new ReadableStream()
(will get a more detailed error when I revert to this scenario).
Tell me if there any other necessary information 😁
But the main question is:
What is the proper way to make a http reauest inside a createServerData$
?rkarmark
04/21/2023, 6:40 PMbash
curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh; chmod +x dotnet-install.sh; ./dotnet-install.sh -c 7.0 -InstallDir ./dotnet7; ./dotnet7/dotnet --version; ./dotnet7/dotnet publish -c Release;
Is there some command to let cloudflare know that if you reach this, then deploy it?Hubchicken
04/22/2023, 5:04 AMErisa | Support Engineer
04/22/2023, 1:42 PMMemeMan
04/22/2023, 4:02 PMnext-on-pages --watch
locally along with wrangler pages dev .vercel/output/static/ --persist --d1 DB
- this works so that I can use the D1 binding but I lose the ability to use fast refresh and have to manually reload the browser to pick up any react changes. Is there any way to use next-on-pages
in a way so that fast refresh can work while still rebuilding _worker.js
on change as well?jeffo
04/23/2023, 2:07 AMimport { getRuntime } from "@astrojs/cloudflare/runtime";
getRuntime(Astro.request);
from https://docs.astro.build/en/guides/integrations-guide/cloudflare/#access-to-the-cloudflare-runtime
this sample code only works in .astro
files where Astro
is globally defined.
instead, use the following to get access to the cloudflare runtime in a typescript endpoint:
import type { APIContext } from 'astro'
import { getRuntime } from "@astrojs/cloudflare/runtime"
export async function get( context: APIContext )
{
const rt = getRuntime( context.request )
...
const id = context.params.id
const val = await rt.env.MY_KV.get( id )
...
}
logging rt
here will look something like this:
rt = {
functionPath: '/foo.json',
params: [Object: null prototype] { path: [Array] },
data: {},
env: {
MY_KV: KVNamespace {},
ASSETS: Fetcher {},
SITE: 'https://example.com',
BASE_URL: '/hello',
FOOBAR: 'SNAFU'
},
waitUntil: [Function: bound waitUntil],
passThroughOnException: [Function: passThroughOnException],
name: 'cloudflare',
next: [AsyncFunction: next]
}
in my local dev environment, the bindings in rt.env
from:
1. .dev.vars
SITE="http://example.com"
BASE_URL="/hello"
FOOBAR="SNAFU"
2. wrangler.toml
kv_namespaces = [
{ binding = "MY_KV", id = "...", preview_id = "..." }
]
hope this helps someone!Simon Thorpe (securitypedant)
04/23/2023, 5:58 AM.Zero
04/24/2023, 6:07 AMcerberus
04/24/2023, 10:14 AMkajtzu
04/24/2023, 10:16 AMnpx wrangler pages publish build --project-name=
to deploy to CF. Reading the forums it seems that many others have stumbled on the same problem 2021 and 2022 without it getting fixed, it seems. So I added a _headers file which overrides the content-type for /*.js
and /*.css
correctly because modern browsers tend to be picky and they do not want to execute .js files unless the mime type is correctly set. This part works but it is really annoying to have to do that.
While troubleshooting this, I noticed an even curiouser case where if I request /index.html I get the file as one would expect, but if I request /assets/index-424242.js I get, instead of the uploaded javascript, file the contents of the top level index.html instead. This obviously breaks everything.
Now, as I build elsewhere, I can prove (to myself) that vite+swc built everything correctly and that there really is a 4.5 MB assets/index-424242.js file in the build root. If I deploy the static javascript stuff to a regular nginx instance anywhere I get the correct files and that's that.
Recap:
- I build and package outside CF
- I use wrangler to upload
- There aren't any functions, I have assumed pages.dev is simply a place that serves files that were uploaded there
- The entire site consists of html, js, svg, css assets
Any ideas on where to start? Any pointers welcome, of course...anhoder
04/24/2023, 10:16 AMValorian
04/24/2023, 10:56 AMxxx.test.pages.dev
- test.pages.dev
- page.test.xyz
(custom domain)
Then I create two Cloudflare Access applications and limit their access to a bunch of emails with the One-Time PIN authentication provider:
- xxx.test.pages.dev
- test.pages.dev
This works well so far, including the limited access in the custom domain. The issue is that files aren't covered by Cloudflare Access on the custom domain, e.g. page.test.xyz/file.js
is not protected by Cloudflare Access.
I tried creating a third Cloudflare Access application at page.text.xyz/*
, which does protect files, but breaks the page with endless redirections.
The post guidelines say to include links and IDs, which unfortunately I can't do publicly, but if necessary I can create a reproduction of this problem with some example files I can actually show.clem.one
04/24/2023, 2:07 PMMigmac
04/25/2023, 4:53 PMUnity WebGL
build to deploy on pages and I can't seem to get the _headers
file right
I need the following files to be functional
/Build/BUILD.data.gz
/Build/BUILD.framework.js.gz
/Build/BUILD.loader.js
/Build/BUILD.wasm.gz
I have tried messing around with the _headers
file to no success
My current _headers
file looks like this:
/*.gz
Content-Encoding: gzip
/*.data.gz
Content-Type: application/octet-stream
/*.wasm.gz
Content-Type: application/wasm
/*.js
Content-Type: application/javascript
/*.js.gz
Content-Type: application/javascript
I do get the following error message when trying to load the page though:
Unable to parse Build/BUILD.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.
Any help would be useful. Thanks in advanceAJ | Aklivity.io
04/25/2023, 9:28 PMcornelius
04/25/2023, 11:45 PMthornAvery
04/26/2023, 4:20 AMskirt
04/26/2023, 12:42 PMluc122c
04/26/2023, 2:59 PM12:55:06.007 Error: Failed to publish your Function. Got error: Unknown internal error occurred.
Seems like a one off and it's fine now, just thought I'd flag it.rodbs
04/26/2023, 4:03 PMconsole.log(sdk.Diagnostics.SetLoggingLevel(sdk.LogLevel.Debug));
const prom = new Promise((resolve, reject) => {
const synthesizer = new sdk.SpeechSynthesizer(speechConfig, null);
synthesizer.speakSsmlAsync(
ssml,
async (result) => {
console.log('RESULT', result);
if (result.errorDetails) {
console.log('1 if ');
console.log('ERROR', result.errorDetails);
synthesizer.close();
} else {
console.log('2 if');
const file = new File([result.audioData], fileName, {
type: 'audio/mp3',
lastModified: Date.now()
});
const res = await context.env.R2_IGLSBKT.put(fileName, file);
console.log('res R2', res);
synthesizer.close();
resolve(fileName);
}
},
(error) => {
console.log('err', error);
synthesizer.close();
}
);
});
await context.waitUntil(prom);
I got this error:
(log) ERROR websocket send error: Websocket not ready 7E9767F5499D4D44AB1AEADF2328152C DA30C36F329148D58231F50472556959 Error
at $e.sendRawMessage (functionsWorker-0.04974505925468953.js:33452:129)
at $e.<anonymous> (functionsWorker-0.04974505925468953.js:33474:22)
at Generator.next (<anonymous>)
at c (functionsWorker-0.04974505925468953.js:33336:13)
My understanding is that WaitUntil
kept the task running in the background until completion. Why then does the ws end before completion? How can I keep running in the background? (I'm in Unbound mode)luddilo
04/28/2023, 11:44 AM