CORS after including Solana Action Headers

CORS after including Solana Action Headers

Manage alerts

Loading saved threads...

Zeus · External communityPost link
External question — Solana Stack Exchange Author: Zeus Original post: https://solana.stackexchange.com/questions/20211 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I was building a solana blink folowing the solana bootcamp 2024, I have included the ACTION_CORS_HEADER as shown in the tutorial and I am still seeing cors error on my frontend my code is attached below import { ActionGetResponse, ACTIONS_CORS_HEADERS } from "@solana/actions"; export async function GET(request: Request) { const actionMetaData: ActionGetResponse = { icon: "https://scontent.fdel8-2.fna.fbcdn.net/v/t39.30808-6/393727018_721291246705301_7329251908952508406_n.jpg", title: "Vote for your favourite Peanut butter", description: "", label: "Vote", }; return Response.json(actionMetaData, { headers: ACTIONS_CORS_HEADERS }); }
Quote
Report
Zeus · External communityPost link
External answer — Solana Stack Exchange Author: Zeus Original post: https://solana.stackexchange.com/a/20212 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. My bad when I was checking on dial.to instead of http I mistakenly typed https, and kept wondering what went wrong
Quote
Report
Amalnath Sathyan · External communityPost link
External answer — Solana Stack Exchange Author: Amalnath Sathyan Original post: https://solana.stackexchange.com/a/21626 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Dial.to Not working for localhost was the error I saw in the console, which led me to figure out, that the dial.to is not having access to my frontend at http://localhost:3000 I installed npm install -g ngrok (ngrok) and ran ngrok http 3000 which gave me a link that's exposed. Then I explicitly changed the href like this. Worked. export async function GET(request: Request) { const actionGetMetadata: ActionGetResponse = { icon: "https://images.pexels.com/photos/1563256/pexels-photo-1563256.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2", title: "Best city to live?", description: "In your opinion, which is the best city to live? Dubai or Tokyo?", label: "vote", links: { actions: [ { https://f107-2405-201-d002-e02d-7d7c-d255-309f-399e.ngrok-free.app:3000/api/vote/api/vote/?candidate=Dubai", label: "Dubai" }, { https://f107-2405-201-d002-e02d-7d7c-d255-309f-399e.ngrok-free.app:3000/api/vote/api/vote/?candidate=Tokyo", label: "Tokyo" }, ], }, }; return Response.json(actionGetMetadata, { headers: ACTIONS_CORS_HEADERS }); }
Quote
Report

Post Reply

Checking account access…