RTC Forums
November 23, 2024, 11:52:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: How can I add headers to the responses from a web server?  (Read 4572 times)
brian71us
RTC Expired
*
Posts: 15


« on: September 16, 2016, 03:56:13 PM »


I am building a web server and providing remote functions using Real Thin Client. The application will need to provide the cross origin (CORS) header to allow the browser to make requests from the server. How do I add a header to the response? I need to add the header 'Access-Control-Allow-Origin' with a value of '*'. It would be best if this could be done directly from the TRtcHttpServer itself so it would work for all remote procedure calls (TRtcFunction).
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 16, 2016, 07:58:23 PM »

You can add any response header using ...

   TRtcDataServer(Sender).Response['response-header-name']:='response-header-value';

... from any RTC event triggered before the response header was sent.

For example, you could do it from the OnRequestAccepted event on the TRtcServerModule component responsible for executing your remote functions if you only want it for remote functions handled by that RtcServerModule, or from the OnRequestAccepted event on the TRtcHttpServer component if you want it for ALL requests accepted for that Server.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.022 seconds with 16 queries.