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.
Code:
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: “https://app.asana.com”,
methods: [“GET”, “PUT”, “POST”],
hook: “onSend”
};
cb(null, corsOptions);
}
});
fastify.route({
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***
}}