This example show how to force trailing slashes using a custom _worker.js
file in your Cloudflare Pages project.
Copy the _worker.js
file into your project's build output directory.
import Image, { ImageLoader } from "next/image"; | |
type Width = [string, number]; | |
const widths = { | |
sm: 640, | |
md: 768, | |
lg: 1024, | |
xl: 1280, | |
}; |
addEventListener('fetch', (event) => { | |
event.respondWith(handleErrors(handleRequest, event.request)) | |
}) | |
const handleRequest = async (request) => { | |
const url = new URL(request.url) | |
switch (url.pathname) { | |
case '/': { | |
const newReleases = await spotify('/new-releases') |
addEventListener('fetch', event => { | |
event.respondWith(handleError(handleRequest, event.request)) | |
}) | |
class InvalidURLPathnameError extends Error { | |
constructor(pathname) { | |
super(`Invalid URL pathname: ${pathname}`) | |
this.name = "InvalidURLPathnameError" | |
} | |
} |
$ wrangler publish
🌀 Using namespace for Workers Site "__scriptname-workers_sites_assets"
🌀 Uploading site files
✨ Success
⬇️ Installing wranglerjs...
⬇️ Installing wasm-pack...
✨ Built successfully, built project size is 241 KiB.
Error: Something went wrong! Status: 400 Bad Request, Details {
"result": null,
I hereby claim:
To claim this, I am signing this object:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtm+POJtqnhn50Fprk36nJucsfw/qg7imvJKFK1+PC3Um4pwln58S7AzaqabmRTQpVHvQPyXUh0200BCDh5EL3kUKfdZ4umB+VsSE+mYGrhXNebYkeilp2TeZ+3XDCFD7u3m2G3buyM8GPGNDuwUoBhE0VqxZ7DzKR314+LDhphMptVQ1dN3up8PhxLrtO9bF3uMj8Kifv6dbBucCvWDYccnyW3/J3+vp/svYSXl1Ea6SL5EtlXQIyBGKosTqqAnxBVK1gAqhAMbBCYKoqajBJWBLz+S1Hc9Hf8ixvkCF9V8E6BGvIcWBo8Qj1NmUgpiyvwCjfPrWfqyw8vhtbr4M4N0K5LDPZs0dsTYfP6hcWakTKz9kivH0bBBDAouvZmriYsNPpkPl3nsMhH5pSXZRS4eb7ZKP1IyXq562MNCVy9mg+eNBH7l9CItjiEDd0z8NsBb8vMiVgstcONYirumlFj438PYtpHSeDtg0NhKF4EbFpFUnKCGrU2l9WbHZczTx1xapOkR9y8mXFgUGaUXYQknmTrgGxXgp+XBHAuZgEwESl9XaEejXnlq4JbdYc8GI2ii8cmrKs0RxCJICoZlbJe/iHnUdumi2XVqwyGLlQqPc7vYZyOvvuqRbkgiJKTCSL2s5P/nHpjWH1WTGw6ODcuO++bOPCqnKaW7OgdaFBAQ== developer@gregbrimble.com |
echo "Hi, "$USER"! Welcome to the SSH permissions fixer." | |
echo "Fixing '~/.ssh' folder permissions..." | |
chmod -R 700 ~/.ssh | |
echo "Done." | |
echo "Fixing all keys (e.g. '~/.ssh/id_rsa') and their public components (e.g. '~/.ssh/id_rsa.pub')..." | |
chmod 600 ~/.ssh/* && chmod 644 ~/.ssh/*.pub | |
echo "Done." |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew tap caskroom/cask | |
brew cask install google-chrome | |
brew cask install atom | |
apm install minimap file-icons todo-show | |
defaults write com.apple.dock static-only -bool TRUE; killall Dock | |
defaults write ~/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool FALSE | |
git config --global user.name "Greg Brimble" | |
git config --global user.email developer@gregbrimble.com | |
git config --global core.editor atom |