Skip to content

POST

Proxies a POST request to the specified postUrl with the payload provided in the request body.

Usage

./frames/route.tsx
export { GET, POST } from "@frames.js/render/next';

Request

  • URL Query Parameters:
    • postType (optional): A string indicating the type of the POST request. It can be either post_redirect to handle redirects manually or tx for transaction requests.
    • postUrl (required): The URL to which the POST request should be proxied.
  • Body: JSON payload conforming to the FrameActionPayload structure imported from frames.js.

Response

The response varies depending on the postType and the status of the request to the postUrl.

  • For a 302 status code from postUrl:
    • Returns a JSON object containing the location header value from the response, with a status code of 302.
  • For postType of tx:
    • Returns the JSON response received from the postUrl.
  • For other responses:
    • Attempts to extract a frame from the HTML content returned by the postUrl, using the getFrame function from frames.js. Returns a JSON object containing the frame data and any errors encountered during the frame extraction process.

Errors

  • Returns a response generated by Response.error() in case of:
    • Absence of the postUrl parameter in the request.
    • Any fetch operation or processing errors.