Modal Form "Something went wrong. Try again later." @fastify/cors

I’ve been having trouble getting my modal form to load in Asana. The entry point and modal form are set up in the app components, the server is receiving the request, the server is sending back the form long before the expiration and the JSON it is trying to send back works fine in the UI builder. I am assuming at this point it is a CORS issue, and I have had no experience with CORS up to this point. I could also be making some other stupid mistake with sending the data back. Since I’m not getting back any error messages from Asana, I’m having trouble figuring out what I’m doing wrong. I’m going a little batty going back and forth between all the documentation and trying a bunch of changes that don’t seem to help at all. I would appreciate any help offered.

const path = require(“path”);
const fs = require(“fs”);
const fastify = require(“fastify”)({

logger: false,


fastify.register(require(“@fastify/cors”), (instance) => {
return (req, cb) => {
const corsOptions = {
origin: “”,
methods: [“GET”, “PUT”, “POST”],
hook: “onSend”

cb(null, corsOptions);


method: “GET”,
url: “/asana/form”,
schema: {
querystring: {
workspace: { type: “string” },
task: { type: “string” },
user: { type: “string” },
locale: { type: “string” },
expires_at: { type: “string” },
handler: async (request, reply) => {

**** Code to make sure metadata fields are updated ****
return reply.code(200).send(formtype);

Metadata (formtype):
“template”: “npform_metadata_v0”,
“metadata”: {
*** All this works in the UI builder***

Hi @Kariah_Petrille,

Not a sure bet, but do you see anything in the browser console? The requests come directly from the browser (hence the need for CORS), so sometimes you can get a meaningful error there. Should indicate if it’s a CORS issue at least.

The browser console isn’t telling me anything specific to loading the form. All the logs were there when I loaded the task page.

Figured it out. I needed both the onRequest and onSend hooks for it to work. I tried both individually and got no indication if I was going in the right direction from either the server console or the client console. Gave both together and shot and now it works.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.