Skip to main content
Question

CORS Issues with Create Figma Plugin Using LemonSqueezy for License Management

  • February 26, 2025
  • 0 replies
  • 38 views

Mastro
  • New Participant
  • 6 replies
Hello everyone,

I'm developing a Figma plugin with Create Figma Plugin toolkit that uses LemonSqueezy for license management, but I'm encountering persistent CORS issues. Despite implementing various solutions, I keep receiving errors like:

Access to fetch at 'https://api.lemonsqueezy.com/v1/licenses/validate' from origin 'null' has been blocked by CORS policy

Problem Context

My plugin needs to validate licenses using the LemonSqueezy API. I've implemented a system where:
  1. The main thread (main.ts) sends API requests to the UI thread (ui.tsx) via figma.ui.postMessage()
  2. The UI thread performs the fetch requests and returns results to the main thread

What I've Already Tried

  1. Using a CORS proxy: I've attempted to use api-cors-anywhere.lemonsqueezy.com instead of api.lemonsqueezy.com, but still receive CORS errors.
  2. Implementing a UI-Main communication system: I've created a system where:
    • The main thread sets an isUiReadyForApi flag when the UI is ready
    • API requests are only sent when this flag is true
    • The UI thread sends a UI_READY_FOR_API event when it's ready to handle requests
  3. Handling requests through the UI: I've implemented an API service in the UI that handles requests and returns results to the main thread. 
  4. Adding domains in manifest.json: I've added the following domains in the manifest:
   "networkAccess": {
     "allowedDomains": [
       "https://api.lemonsqueezy.com",
       "https://*.lemonsqueezy.com",
       "https://api-cors-anywhere.lemonsqueezy.com"
     ]
   }

 

 

Current Behavior

Despite these changes, when the plugin loads, I still see CORS errors in the console. It appears that some requests are still being executed directly from the main thread instead of going through the UI thread.

 

Questions

  1. Is there a correct way to handle external API requests in a Figma plugin to avoid CORS errors?
  2. Could there be a timing issue where requests are being executed before the UI is fully ready?
  3. Does anyone have experience integrating LemonSqueezy (or similar license management systems) into a Figma plugin using the toolkit Create Figma Plugin?
  4. Is there a better way to debug the communication flow between the main thread and the UI thread?

 

Any suggestions or shared experiences would be greatly appreciated!
Thank you in advance.

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings