IR
irwinrodriguez.dev
Back to docs

Configuration

Each server is a JSON file (its manifest) in config\servers\. It is created by foxserver init and updated by the hook at compile time; you can also edit it by hand, and FoxForge edits it with forms from the VFP IDE.

Configuration file location

Each project has its own file at:

C:\Program Files\FoxServer\config\servers\{projectname}.json

Complete example

A complete server manifest
{
  "name": "almacen",
  "description": "API de almacen",
  "type": "api",
  "active": true,
  "host": "127.0.0.1",
  "port": 8098,
  "prefix": "",
  "issecure": false,
  "certificatename": "",
  "certificatepassword": "",
  "root": "C:\\proyectos\\almacen\\",
  "paths": { "data": "data" },
  "dllpath": "build\\almacen.dll",
  "allowedorigins": "https://miapp.com",
  "allowedmethods": "GET,POST,PUT,DELETE,OPTIONS",
  "allowedheaders": "Content-Type,Authorization",
  "lifecycle": {
    "enabled": true,
    "classname": "MiErpLifecycleClass"
  },
  "hotreload": {
    "enabled": false,
    "debouncems": 1500,
    "maxretries": 3
  },
  "server": {
    "checkstatusenabled": true,
    "endpoint": "server/status"
  },
  "middleware": {
    "auth": {
      "enabled": true,
      "type": "jwt",
      "secret": "",
      "tokenexpirationseconds": 3600,
      "loginendpoint": "auth/login"
    },
    "logging": {
      "enabled": true,
      "path": "logs\\",
      "fileprefix": "almacen",
      "format": "Detailed",
      "options": {
        "requests": true,
        "responses": true,
        "errors": true,
        "debug": false,
        "performance": true
      }
    }
  }
}
The JWT secret is EMPTY in this example on purpose, and so is the certificate: a sample manifest with something that looks like a key ends up copied verbatim into production. The manifest lives in config\servers\ next to the license (config\foxserver.lic), so treat that folder for what it is: secrets.

Server properties

PropertyTypeDefaultDescription
name String — Unique project/server identifier
description String "" Human-readable description
type String api "api" for REST APIs, "web" for serving static files
active Boolean false Whether the server loads on FoxServer startup
host String 127.0.0.1 Bind address. 0.0.0.0 accepts all interfaces
port Number 8080 HTTP listening port
prefix String "" URL path prefix (e.g. "/api/v1")
issecure Boolean false Enable HTTPS/SSL
dllpath String — Path to the project's compiled MTDLL (required). Since 0.9 the engine activates by ProgID, so this path points at the native VFP DLL, not at a .NET assembly
publicdir String "" Static files directory (type: web only)
root String "" Project folder. The relative paths of the manifest count from here (see Relative paths, below)
paths Object {} Named folders, for this.Path("name") in the controller

CORS

Configure allowed origins, methods and headers for cross-domain requests:

{
  "allowedorigins": "https://app.example.com,https://admin.example.com",
  "allowedmethods": "GET,POST,PUT,DELETE,OPTIONS",
  "allowedheaders": "Content-Type,Authorization,X-Requested-With"
}
PropertyTypeDefaultDescription
allowedoriginsString*Allowed domains separated by comma, or "*" for any
allowedmethodsStringGET,POST,PUT,DELETE,OPTIONSHTTP methods allowed from the browser
allowedheadersStringContent-Type,AuthorizationHeaders the client can send
In production, always specify exact domains instead of "*" for better security.

HTTPS / SSL

To enable HTTPS you need a certificate in .pfx or .p12 format:

{
  "issecure": true,
  "certificatename": "mycert.pfx",
  "certificatepassword": "your-cert-password"
}
Never include certificate passwords in version control. Use environment variables or a secret manager.

Relative paths and named folders

Since 0.9.40 the manifest can say where the project lives with root, and its paths become relative to that folder. A project then moves to another folder or another machine by changing one line. A manifest without root works as it always did.

{
  "root": "C:\\proyectos\\almacen\\",
  "paths": {
    "data": "data",
    "facturas": "\\\\srv\\erp\\facturas"
  },
  "dllpath": "build\\almacen.dll",
  "middleware": { "logging": { "path": "logs\\" } }
}
Program1
use (this.Path("data") + "clientes") shared
  • root is the project folder. When it is relative, the server resolves it against the FoxServer installation folder (the one that holds bin): "projects\almacen" ends up in C:\Programas\FoxServer\projects\almacen.
  • dllpath, publicdir, certificatename, the log folder, the webhook folders and every folder in paths are resolved against root, once, at startup.
  • paths gives your folders a name. The controller opens its tables with this.Path("data"), which returns the full folder with its trailing backslash. A name that is not in paths is an error that says so.
  • Always open tables through this.Path(), never with a relative path: the current directory is shared by every thread of the server.
  • Without root, paths counts from the DLL folder and the other paths keep their meaning. A project created with 0.9.40 is born with root.
  • Available since FoxServer 0.9.40.

From the command line

foxserver root-set --project C:\proyectos\almacen --root .
foxserver path-add --project C:\proyectos\almacen --name data --folder data
foxserver path-list --project C:\proyectos\almacen
foxserver path-remove --project C:\proyectos\almacen --name data
foxserver deploy --project C:\proyectos\almacen --root projects\almacen

root-set with a dot sets the project folder and turns the paths that already hung from it into relative ones. deploy writes root into the copy it leaves in the installation: the one you give it, or the deployment.path of the manifest. If you move the folder, register the DLL again, with an elevated regsvr32 or with foxserver build: the server activates it through the Windows registry, and root-set warns you when it is still registered in the old folder.

Redirects (web sites)

Since 0.9.36 a site of type web can answer that something lives at another URL. The rules go in the redirects list of the manifest, and the server checks them before looking for the file on disk. A rule takes precedence over whatever is in publicdir, so it also works to retire the URL of a file that is still there, such as the installer of an old version.

{
  "type": "web",
  "redirects": [
    {
      "from": "/kit/FoxAgent-Setup-1.63.2.exe",
      "to": "/kit/retired/",
      "status": 302
    },
    {
      "from": "/old-docs/",
      "to": "/docs/",
      "status": 301,
      "match": "prefix"
    }
  ],
  "trailingslashredirect": true
}
PropertyTypeDefaultDescription
fromString(required)Path the client asks for, starting with /. It is compared with the whole path (server prefix included), decoded and case-insensitive.
toString(required)Target: a path on the same site or an absolute URL (https://...).
statusNumber302301 and 308 are permanent and the browser remembers them. 302 and 307 are temporary and are sent with Cache-Control: no-store.
matchStringexactexact matches the whole path. prefix matches everything that starts with from and appends the rest to to: /old-docs/a/b goes to /docs/a/b.
  • The first rule that matches wins, in the order of the file.
  • The query string of the request travels to the target, unless to has its own.
  • The response carries Location and a minimal HTML page with the link, for clients that do not follow redirects. A HEAD request gets the headers only.
  • A badly written rule is skipped at startup, with a log warning that says which one and why: from without the leading slash, an empty to, a status outside the list, an unknown match or an obvious loop (a prefix rule whose to starts with its own from). The server starts anyway and the other rules keep working.
  • Only a site of type web applies them. A server that serves REST dispatches through the API and ignores them; foxserver validate warns about it.
  • The server reads the rules when it starts. Restart it after changing them.

The trailing slash of folders

With "trailingslashredirect": true, a folder requested without its trailing slash (/docs/guide) answers 301 to the same path with the slash (/docs/guide/) and keeps the query string, as nginx, Apache or IIS do. Each page then lives at a single URL and its relative links point at the right folder. It is off by default because it changes what an already published site answers, and that is up to whoever publishes it.

From the command line

foxserver redirect-add --project C:\proyectos\web --from /kit/FoxAgent-Setup-1.63.2.exe --to /kit/retired/
foxserver redirect-add --project C:\proyectos\web --from /old-docs/ --to /docs/ --status 301 --match prefix
foxserver redirect-list --project C:\proyectos\web
foxserver redirect-remove --project C:\proyectos\web --from /old-docs/
foxserver redirect-trailing-slash --project C:\proyectos\web on

These commands edit the project manifest (build\) and reach the server with foxserver deploy, like the rest of the configuration. A redirect-add with a from that already exists replaces that rule in place. Saving the project from FoxForge or from the CLI keeps rules written by hand, including fields the tool does not know.

Logging

Configure the server logging system:

PropertyTypeDefaultDescription
enabledBooleanfalseEnable / disable logging
pathString—Directory where log files are written (must exist)
fileprefixStringfoxserverFile name prefix. Result: "{prefix}_2026-04-11.log"
formatStringSimple"Simple" (one line), "Detailed" (full info), "JSON"
options.requestsBooleantrueLog incoming requests
options.responsesBooleantrueLog outgoing responses
options.errorsBooleantrueLog errors
options.debugBooleanfalseLog debug messages (more verbose)
options.performanceBooleanfalseLog response times per endpoint
excludeArray[]Routes that are not logged (see below)

Routes that stay out of the log

A route that is called all the time (a polling loop, a health check) fills the logs with entries that say nothing. With "exclude" inside "logging", its requests are not written:

"logging": {
  "enabled": true,
  "exclude": [
    { "method": "GET", "path": "/api/slots/*/poll", "status": [204] },
    { "path": "/api/health" }
  ]
}
  • "path" is the whole path the client asks for, with the server prefix and without the query string, compared without case. A "*" segment stands for any one segment, and only one: /slots/*/poll matches /slots/123/poll but not /slots/1/2/poll.
  • "method" is optional. Without it, the rule applies to every method.
  • "status" is optional: one code or a list. With it, the request is left out only when it is answered with one of those codes, so a 200 or a 500 on the same route is still logged.
  • A rule removes the request from the Request, Response and Performance logs and from the VFP traces (VfpRequest and VfpResponse). Those traces are written while the controller runs, before the response code exists, so for them only the method and the path count.
  • Server errors are always logged. A malformed rule is dropped at startup with a warning in the host log, and the server starts anyway.
  • Available since FoxServer 0.9.39.

Responses the host answers itself

Since 0.9.41 the server can answer on its own the requests that repeat all the time, such as a polling loop that almost always gets a 204. Your controller says in the response how long it stays valid, with the usual Cache-Control header, and the manifest says on which routes it may be stored. While it is valid, the server repeats it without going into VFP and adds the Age header. The section goes inside "middleware":

"responsecache": {
  "enabled": true,
  "routes": [
    { "method": "GET", "path": "/api/slots/*/poll",
      "vary": ["X-Slot-Secret"], "maxage": 600, "status": [204] }
  ],
  "maxentries": 10000,
  "maxbodybytes": 16384
}
PropertyTypeDefaultDescription
enabledBooleanfalseTurns the section on. Without it, the server behaves as before.
routes[].pathString(required)The whole path the client asks for, with the server prefix and without the query string. A "*" segment stands for any one segment, as in exclude.
routes[].methodStringGETGET or HEAD. A GET rule also covers HEAD. Any other method drops the rule: a cache never answers a write.
routes[].varyArray[]Request headers that are part of the key: what was stored for one value is never served for another. The server keeps the SHA-256 of the value, not the value.
routes[].maxageNumber3600Upper limit in seconds on what the controller asks for. With 0, the route stores nothing.
routes[].statusArray[200, 204]The codes that may be stored: one or a list.
maxentriesNumber10000Responses kept in memory per server. When the table is full nothing else is stored, and the log says so once.
maxbodybytesNumber16384A response with a larger body is not stored.

How the controller asks for it

With res.header, in a method that answers through res. If the method returns its result (return this.Ok(...), this.NoContent()...), the server does not read the headers of res and nothing is stored.

Program1
procedure pPoll(req, res) help "GET: slots/{slot}/poll public"
    res.status(204)
    res.header("Cache-Control", "max-age=600")
endproc
  • Only the response to a GET is stored, when it matches a rule, has one of the rule's status codes and carries a Cache-Control with a max-age above 0 and none of no-store, no-cache or private. It lasts the smaller of max-age and maxage.
  • A POST, PUT, PATCH or DELETE answered without an error (below 400) removes what was stored for its route, for every client, and also for the route named by its Location or Content-Location. A 409 removes nothing.
  • A POST to the server status route followed by /reload empties the table. When the server restarts, it starts empty.
  • Never stored: the response to a HEAD (it is answered from what the GET stored, without a body), a response with Set-Cookie, the server's own errors, a route that is not public while authentication is on, or anything for another machine when the license only serves localhost.
  • A response that comes from the cache leaves no access line on the console and does not enter the project logs. At startup the log says Server <name>: response cache on, N route(s), and the server status counts the hits in responsecache.hits.
  • s-maxage is not supported: the server only looks at max-age, no-store, no-cache and private. What nobody invalidates lasts until its max-age.
  • A malformed rule is dropped at startup with a warning, and the server starts anyway. FoxForge and the CLI do not know the section yet: it is written by hand, and saving the project keeps it.
  • Available since FoxServer 0.9.41.

Next: Routing →