How to Enable CORS from Nodejs server

hello guys hope you all are doing great,
i have deployed my node server through cyberpanel but when i am accessing it through live website its showing cors error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at…
i have enabled cors
its not showing error when i am accessing it from my localhost but when i am accessing it through live website its showing cors error
I am not able to find out what might be the problem

Happy New Year @midnyt

This question is unrelated to cyberpanel however I will answer it.

To enable CORS on your node server you have to add the following headers to your requests:

  1. Access-Control-Allow-Origin
  2. Access-Control-Allow-Headers

If you are using express js checkout Express cors middleware

I recommend you check other forums such as stackOverflow for more help on how setup this in your code.

@josephgodwinke,thanks for answering but i have enabled cors, what i think the problem is that
my node server is hosted on my cyberpanel:PORT, and my cyberpanel doesnot have a ssl yet
so how can i enable ssl in my cyberpanel, i think that might solve my problem

Follow this guide 1 - Issuing SSL for website - Docs - CyberPanel Community