Jump to content
Sign in to follow this  
misc_bb

CORS issue on TServermethod in Datasnap

Recommended Posts

I'm recently facing an issue with a POST API call to my Servermethod function. I understand we can add a code to allow CORS header but I think that was applicable for Webmodule. I don't think this line of code is applicable in my servermethod function: 

Response.SetCustomHeader('Access-Control-Allow-Origin', '*');

 In my case the function is directly called from front-end thru Axios, it works fine when it is using GET but since we want to pass a JSON, we want to apply a POST call. The call is coming from a different subdomain. Works fine within localhost testing and the same domain configuration. Is there a workaround for this to work? Sample code here. Any thoughts on a possible solution would be appreciated. Thank you. 

 

axios.post('https://url/staging.dll/datasnap/rest/TServerMethods1/"GetAllCompanies"/', requestBody,{
        headers: {
          'Content-Type': 'application/json' // Specify JSON format
        }
      })
 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×