WEBCORE Configuration file


I have a WebCore Project with a differents functionalities. This functionalities was based on data that i retrieve from database using Rest calls to a remote Rest Server usinf httprequest...

The purpose of this project is to be deployed in different servers ans installations... But i want only one version of the project.

In the project, when i want to call a method of a rest server i write the uri like this: https://customers.madd.com/univers/rm/rmserver/......

The variable part of uri is the base url... https://customers.madd.com

This part is different in all the servers...

I would like to have an .ini file (for example) on the server, in the location of the apache html where i edit ans put into this and other parameters...

Then, when i use the html in the client side i see into this file what is the url of the rest server for call methods... or any other parameters that i can nedd...

You know how can i do this ? Any idea for the best practice to do this ?

Thanks !

You should be able to use a TWebHTTPRequest to request the content of this config file and use this content in your code.

Hi Bruno,

Yes i do this with TWebHTTPRequest as you say. For example:


This code retrieve to my data from rest server...

Rest Server is located in

I put this value ( in a global variable or in a local TWebLocalDataStore in the mainform an i can read this value along the web when i need it, etc...

If this project is installed and run in one server, all is ok...

But i want to use this project for install in any other servers, and the rest server of any installation is in the different url... Then i want to have, for example, one INI file in the /var/www/html folder of the server for indicate the singular url for this server in order that the html use this value for the TWebHTTPRequestURL...

For example, in this project there are one image for the logo of my customer... This image is in the TTMSFNCImage component in the webform. Then, in the form, in the event of OnCreate of he form i do:


Then in the folder of /var/www/html/ are a logo.png file..

When i install a new web application for other customer, i put their logo in this file, and in the web their logo appear and i not have to modify my source code...

I want to do the same with the URL of rest server...

Do you know how can i do this ?


I use a JSON file for my config and use (I'm using XData) and store the config file in the subdirectory of the website config:

Conn := TXDataWebConnection.Create(Nil);
    Conn.SendRequest(THttpRequest.Create('config/config.json'), @OnSuccess, @OnError);

If I was doing this now I'd use Await(IHttpResponse, SendRequestAsync)

In OnSuccess I retrieve the URLs:

Procedure OnSuccess(Response: IHttpResponse);
    Obj: TJSObject;
    Config: TAppConfig;
    lResponse: String;
    Config := TAppConfig.Create;
      If Response.StatusCode = 200 Then
        lResponse := Response.ContentAsText;
        Obj := TJSObject(TJSJSON.parse(lResponse));

        If JS.toString(Obj['BaseUrl']) <> '' Then
          Config.BaseUrl := JS.toString(Obj['BaseUrl']);
        If JS.toString(Obj['AuthUrl']) <> '' Then
          Config.AuthUrl := JS.toString(Obj['AuthUrl']);

1 Like

Hi Russell,

I do not use XData but i think that i can do the same with TWebHTTPRequest...

I try it...

Thanks for your response !

1 Like

Yes you should be able to do that.

Hi Russell,

Your solution works perfectly for me.

Thanks for your help !

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.