micromashor
05/25/2023, 4:43 PMSkye
05/25/2023, 4:43 PM_worker.js
directory instead, where the _worker.js/index.js
file is your normal worker, and anything in that directory isn't uploaded as a static assetSkye
05/25/2023, 4:44 PM_worker.js
file which is a little differentmicromashor
05/25/2023, 4:44 PMSkye
05/25/2023, 4:44 PMWalshy | Pages
05/25/2023, 4:45 PMSkye
05/25/2023, 4:45 PMWalshy | Pages
05/25/2023, 4:45 PMWalshy | Pages
05/25/2023, 4:45 PMSkye
05/25/2023, 4:45 PMWalshy | Pages
05/25/2023, 4:45 PMmicromashor
05/25/2023, 4:46 PMSkye
05/25/2023, 4:46 PMmicromashor
05/25/2023, 4:46 PMWalshy | Pages
05/25/2023, 4:46 PMmicromashor
05/25/2023, 4:47 PMmicromashor
05/25/2023, 5:22 PMError: Failed to publish your Function. Got error: multipart uploads must contain a readable body_part or main_module
Lloyd
05/26/2023, 1:56 PMany
for this typescript middleware
ts
const abTest = async ({ request, next, env }) => {
const url = new URL(request.url)
// if homepage
if (url.pathname === "/") {
Lloyd
05/26/2023, 1:56 PMMiddleware
types that I can seeLloyd
05/26/2023, 2:01 PMconst abTest: PagesFunction = async ({ request, next, env }) => {
is valid?Unsmart | Tech debt
05/26/2023, 2:01 PMLloyd
05/26/2023, 2:01 PMLloyd
05/26/2023, 2:01 PMehesp
05/26/2023, 4:02 PMFailed to publish your Function. Got error: Error: Script startup exceeded CPU time limit.
error.
I've tried to dynamic import everything where possible outside of the global scope, but this error frequently comes up on deployments... but randomly also works with no changes. It's becoming so regular that we're struggling to deploy changes without constant redeployment attempts. Lots of Googling really doesn't help, there just seems to be no way to debug or profile the code to identify where the issue lies 😦Lloyd
05/26/2023, 4:43 PMts
const exampleShortenedUrls: ShortenedUrl[] = [
{ id: '2tg9xy3', url: 'https://example.com' },
{ id: '3f2tqv', url: 'https://en.wikipedia.org/wiki/Example.com' },
{ id: '48difn', url: 'www.google.com' },
];
...
const { pathname } = new URL(request.url);
const id = new URL(request.url).pathname.startsWith('/')
? pathname.slice(1)
: pathname;
const matchedUrl = exampleShortenedUrls.find((entry) => entry.id === id);
if (!matchedUrl) {
console.warn('Unable to find shortened URL', id);
} else {
console.info('Found shortened URL and redirecting user', id);
Response.redirect(matchedUrl.url, 302); // this does nothing?
}
return next();
"logs": [
{
"message": [
"Found shortened URL and redirecting user",
"2tg9xy3"
],
"level": "info",
"timestamp": 1685119189434
}
],
Erisa | Support Engineer
05/26/2023, 4:44 PMnext()
, return an empty response or something else?Lloyd
05/26/2023, 4:45 PMErisa | Support Engineer
05/26/2023, 4:45 PMErisa | Support Engineer
05/26/2023, 4:45 PMResponse.redirect
but you don't return it