Configuration
Stubr is being configured by providing a configuration object to the constructor. The configuration is optional since Stubr assumes sensible default values.
Configuration Options
| Property | Type | Default Value | 
|---|---|---|
| stubsPort | number | 4000 | 
| uiPort | number | 3000 | 
| corsEnabled | boolean | true | 
| corsAllowOrigin | string | * | 
CORS Handling
By default, Stubr has CORS handling enabled. As such it answers incoming OPTIONS requests by providing CORS headers with wildcard values (i.e. *).
You can modify that behaviour by either limiting allowance to only the provided domain (i.e. by setting a value to corsAllowOrigin configuration) or disabling CORS treatment entirely (i.e. by setting corsEnabled to false).
Example
const stubr = new Stubr({
    stubsPort: 4001,
    uiPort: 3001,
  	corsAllowOrigin: "example.com"
});
Updated over 3 years ago