Closed14

Fastly の Compute@Edge に Next.js をデプロイしてみる

N04hN04h

と思ったらなんか壊れた

==> Pouring python@3.10--3.10.7.x86_64_linux.bottle.tar.gz
Error: Input/output error @ io_fread - /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.7.rb
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.sh: line 544: cannot create temp file for here-document: Read-only file system
Error: Please update your system Git or set HOMEBREW_GIT_PATH to a newer version.
Minimum required version: 2.7.0
Your Git version: ...
Your Git executable: 
Error: Input/output error @ io_fillbuf - fd:5 /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/doctor.rb
N04hN04h

ディスクフルだったので、容量あけて以下した

brew reinstall fastly

ヨシッ!

fastly version

Fastly CLI version v4.0.1 (cc0afc7)
Built with go version go1.18.6 linux/amd64
N04hN04h

ビルドして、Fastlyの必要なファイル群をつくってもらう

npm run build
npx @fastly/next-compute-js
N04hN04h

fasltyのローカルで起動できるサーバーを立ち上げてみる

cd compute-js
fastly compute serve

とおもったらNode.js v16.16.0が必要とのことだったので入れる

asdf install nodejs 16.16.0
node -v
N04hN04h

おーできたできた

curl http://127.0.0.1:7676/api/user/fuga
{"name":"fuga"}
N04hN04h

でぷろい!!!!!!

❯ fastly compute publish
✓ Initializing...
✓ Verifying package manifest...
✓ Verifying local javascript toolchain...
✓ Running [scripts.build]...
✓ Creating package archive...

SUCCESS: Built package (pkg/package.tar.gz)


There is no Fastly service associated with this package. To connect to an existing service
add the Service ID to the fastly.toml file, otherwise follow the prompts to create a
service now.

Press ^C at any time to quit.

Create new service: [y/N] y

Service name: [nextjs-template-next-compute-js-app] Next.js on Fastly Compute@Edge
✓ Initializing...
✓ Creating service...

Domain: [ghastly-enhanced-boar.edgecompute.app] nextjs-on-fastly.n04h.jp

Backend (hostname or IP address, or leave blank to stop adding backends):

✓ Creating domain 'nextjs-on-fastly.n04h.jp'...
✓ Uploading package...
✓ Activating version...

Manage this service at:
        https://manage.fastly.com/configure/services/XXXXXXX

View this service at:
        https://nextjs-on-fastly.n04h.jp


SUCCESS: Deployed package (service XXXXXXX, version 1)
N04hN04h

できた!SSL対応がいまいちわからん

curl https://nextjs-on-fastly.n04h.jp/api/user/nya
{"name":"nya"}
このスクラップは2022/10/07にクローズされました