Zizzamia / a-frame-in-100-lines

Farcaster Frames in less than 100 lines, and ready to be deployed to Vercel.
https://onchainkit.xyz
MIT License
226 stars 256 forks source link

Bug: When running it in conjunction with framegear an error occurs when handling the submit from "Story time" action #17

Open claudioantonio opened 2 months ago

claudioantonio commented 2 months ago

Steps to reproduce

  1. clone this repo
  2. npm install
  3. npm run dev to run a-frame-in-100-lines app
  4. clone onchainkit repo
  5. cd /framegear
  6. npm install
  7. npm run dev
  8. get url provided in 3 and paste it into the input field on framegear website and then press Fetch button
  9. the frame will be presented on framegear website
  10. enter any text in the input field of the frame being rendered and then press "Story time"
  11. you will see an error on the backend of a-frame-in-100-lines app

The error message

FetchError: non-200 status returned from neynar : 400
    at Object.postDataToNeynar (webpack-internal:///(rsc)/./node_modules/@coinbase/onchainkit/lib/utils/neynar/postDataToNeynar.js:18:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.neynarFrameValidation (webpack-internal:///(rsc)/./node_modules/@coinbase/onchainkit/lib/utils/neynar/frame/neynarFrameValidation.js:7:26)
    at async getFrameMessage (webpack-internal:///(rsc)/./node_modules/@coinbase/onchainkit/lib/frame/getFrameMessage.js:20:22)
    at async getResponse (webpack-internal:///(rsc)/./app/api/frame/route.ts:14:34)
    at async /home/claudio/src/cartesi/a-frame-in-100-lines/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62499

Extra comments

This repo is using onchainkit library 0.14.1 and the framegear app on onchainkit's repo is using onchainkit library version 0.15.0. I updated this repo to version 0.15.0, but the error is the same.

claudioantonio commented 2 months ago

Reading onchainkit docs, I found the solution:

When using the getFrameMessage function, include the allowFramegear option to enable Framegear to send mock frame actions. After adding the allowFramegear option it worked as expected.

But the docs suggest a protection:

import { getFrameMessage } from '@coinbase/onchainkit/frame';
const allowFramegear = process.env.NODE_ENV !== 'production'; 
// ...
const { isValid, message } = await getFrameMessage(body, {
  allowFramegear, 
});