# Environments

{% hint style="info" %}
**Good to know**

The number of available environments in your solution depends on your subscription tier. Read more about deploying across the different environments [here](https://docs.appfarm.io/operations/deploy#environments).
{% endhint %}

You can configure each Appfarm Client environment in your solution separately. You can enable or disable platform features, set solution-wide defaults that will apply across all apps, and customize settings to ensure your apps work as expected.

It is common to maintain different environment configurations, particularly between Development and Production. For example, in Development and Test it is very helpful to have client logs enabled but this is not typically enabled in Production. On the other hand, you might have Schedules enabled in Production, but not in any other environment.

In general, it is a good idea to only enable the features and configurations that are required for your apps and services to run in a given environment. This will help keep your solution safe from unintended issues.

## Enable/Disable Environment

Solution [Owners](https://docs.appfarm.io/security/roles#built-in-roles) can enable and disable Development, Test, and Staging environments (if available on your subscription tier) from the Environment Configuration page. For Production environment changes, contact your Appfarm representative. When enabling an environment for the first time, you must deploy a version before it becomes accessible. You can configure environments before enabling them. Disabling an environment takes it offline while preserving all data until you re-enable it. To disable an environment, use the button at the bottom of the environment configuration page (see image below).\
Note: after enabling/disabling an environment, a refresh is required before the environment status is reflected in the Dashboard and the Deploy page.

{% hint style="warning" %}
**Important**

* The Staging environment uses the Production database. Any changes made to data in Staging will be reflected in Production.
* Users exist across all environments. For example, a user created in Production can be deleted in Test. See [Users](https://docs.appfarm.io/reference/security/users) for more details.<br>
  {% endhint %}

<figure><img src="https://29237295-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MiLU-xcHu0eLZiTxcmZ%2Fuploads%2FugN6hf8KdiirzxkmkQxE%2Fimage.png?alt=media&#x26;token=be2723c5-c062-4d68-a23c-a45e5f708705" alt="" width="563"><figcaption><p>The Environment Configuration page with the "Disable Environment" button at the bottom</p></figcaption></figure>

## General settings

<table><thead><tr><th width="259">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Login Config</strong></td><td>Assign a <a href="login">login configuration</a>.</td></tr><tr><td><strong>Enable GraphQL</strong></td><td>Enable <a href="../data-model/graphql">GraphQL</a> access.</td></tr><tr><td><strong>Enable GraphQL Auxilary Endpoints</strong></td><td>Will enable a built-in endpoint for all GraphQL enabled Object Classes with built-in <a href="../../data-model/object-classes#meta-data">Random Identifier</a>. This endpoint may be used to update this identifier of existing records. Read more <a href="../../data-model/graphql/mutations#generate-random-identifiers">here</a>.</td></tr><tr><td><strong>Enable GraphQL Explorer</strong></td><td>Enable <a href="../../data-model/graphql#graphiql-ide">GraphiQL</a>, a web-based tool for running GraphQL queries and mutations to see and modify the data in the database.</td></tr><tr><td><strong>Enable API Services</strong></td><td>Enable <a href="../services">services</a> to run.</td></tr><tr><td><strong>Enable API Explorer</strong></td><td>Enable the a user interface for <a href="../services/api-explorer">documentation and testing of services</a>.</td></tr><tr><td><strong>Enable Scheduler</strong></td><td>Enable <a href="../operations/schedules">schedules</a> to run.</td></tr></tbody></table>

## Maintenance

<table><thead><tr><th width="282">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Enable Maintenance Mode</strong></td><td>Show a maintenance mode page to all users in the Appfarm Client and disable access to apps.</td></tr><tr><td><strong>Maintenance Mode Text</strong></td><td>Text to show on the maintenance mode page.</td></tr><tr><td><strong>GraphQL Maintenance Mode</strong></td><td>Return <code>503 Service Unavailable</code> on all <em>external</em> requests to the GraphQL endpoint.</td></tr><tr><td><strong>Services Maintenance Mode</strong></td><td>Return <code>503 Service Unavailable</code> on all <em>external</em> requests to services endpoints. Schedules are not affected by this setting. To prevent schedules from triggering services, clear either <strong>Enable Scheduler</strong> or <strong>Enable API Services</strong>.</td></tr></tbody></table>

## Email settings

<table><thead><tr><th width="288">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Email Provider</strong></td><td><p>Choose between Appfarm, <a href="../../../how-to/integrations/configure-mailgun-account#mailgun">Mailgun</a>, <a href="../../../how-to/integrations/configure-mailgun-account#amazon-ses">Amazon</a><a href="../../../how-to/integrations/configure-mailgun-account#amazon-ses"> SES</a> or <a href="../../../how-to/integrations/configure-mailgun-account#sendgrid">SendGrid</a>.</p><p></p><p>By default, emails sent from a solution use the integrated Appfarm mail server.</p><ul><li>The sender domain is <a href="mailto:noreply@appfarm-mail.com">appfarm-mail.com</a></li><li>The sender name is the solution name</li><li>There is a maximum number of emails that can be sent per month. The limit is specified in your subscription agreement.</li></ul><p></p></td></tr></tbody></table>

## Log options

<table><thead><tr><th width="290">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Enable Client Log</strong></td><td>Print log messages to the browser console. This checkbox must also be selected to enable <a href="../appfarm-client/developer-tools-for-apps">Developer Tools</a>.</td></tr><tr><td><strong>Simulate Messaging Only</strong></td><td>Enable this option to prevent email and SMS messages from being sent. The relevant action nodes will still run, but the actual sending will be simulated. This option can be helpful during development and testing.</td></tr></tbody></table>

## Progressive Web App defaults

These values are serve as defaults for all of your apps in the [web application manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest). They can be overwritten per app in [App Settings](https://docs.appfarm.io/reference/apps/app-settings).

<table><thead><tr><th width="294">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>The name of the app. It may be displayed among a list of other apps or as a label for an icon.<br>Defaults to <code>Appfarm</code>.</td></tr><tr><td><strong>Short Name</strong></td><td><p>An abbreviated name used as the app name on device homescreens and other places with limited space.</p><p>Defaults to <code>Appfarm</code><em>.</em></p></td></tr><tr><td><strong>Orientation</strong></td><td>The default orientation of your app on mobile devices.</td></tr><tr><td><strong>Background Color</strong></td><td>A color that may be used by the operating system as a placeholder while the app's styles are loaded. Usually, this should match the background color of the app.</td></tr><tr><td><strong>Theme Color</strong></td><td>A color that may be used by the operating system when displaying the app. This color may apply even when an app is not installed as a PWA.</td></tr><tr><td><strong>Icon 72x72–512x512</strong></td><td>App icons of various dimensions that can be used in different contexts across an operating system. The icons must be uploaded to <a href="../resources/files">Files</a>.</td></tr></tbody></table>

## Session settings

<table><thead><tr><th width="298">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Absolute Timeout</strong></td><td>The maximum length of a user session before the user must reauthenticate. The default length is 15 552 000 (180 days). The maximum length is 31 536 000 (365 days).</td></tr><tr><td><strong>Renewal Timeout</strong></td><td>The maximum length of a user session before it will not be automatically renewed. The default length is 604 800 (7 days). The maximum length is 5 184 000 (60 days). It is recommended to set this value a little longer than the typical usage period of your apps.</td></tr></tbody></table>

## Content security

By default, Appfarm implements a strict set of content security settings to protect users against common attacks. However, we also allow for easy integration with third-party services and sites and you may need to allow their domains within the following policies.

These settings map directly to the [Content Security Policy (CSP) standard](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy).

<table><thead><tr><th width="304">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Web Request Targets</strong></td><td>Allowed domains that can receive web requests directly from the client. If you only send web requests from the server, which is the default behaviour, you do not need to allow the receiving domains here.</td></tr><tr><td><strong>Font Sources</strong></td><td>Allowed domains that can deliver fonts to the Appfarm Client.</td></tr><tr><td><strong>Frame Targets</strong></td><td>Allowed domains that can be loaded into frame/iframe tags.</td></tr><tr><td><strong>Frame Ancestors</strong></td><td>Allowed domains that can embed the Appfarm Client in frame/iframe tags.</td></tr><tr><td><strong>Image Sources</strong></td><td>Allowed domains that can deliver images to the Appfarm Client.</td></tr><tr><td><strong>Script Sources</strong></td><td>Allowed domains that can deliver scripts to the Appfarm Client.</td></tr><tr><td><strong>Style Sources</strong></td><td>Allowed domains that can deliver stylesheets to the Appfarm Client.</td></tr><tr><td><strong>Allow Insecure Resources</strong></td><td>If enabled, the CSP policy <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/upgrade-insecure-requests">upgrade-insecure-requests</a> will be disabled. This is only required if you embed passive content (images) from sources that must be HTTP instead of HTTPS. You should always prefer HTTPS.</td></tr><tr><td><strong>Public Assets</strong></td><td>Allowing external tools (such as Hotjar) to access and use Appfarm assets (fonts and stylesheets) without authentication.</td></tr></tbody></table>

## Application security

<table><thead><tr><th width="276">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Unauthenticated Access</strong></td><td>Enable this option to be able to serve apps with <a href="../../how-to/authentication-and-access-control/unauthenticated-access">unauthenticated access</a>.</td></tr><tr><td><strong>Service Account</strong></td><td>Unauthenticated apps will run as the <a href="../security/service-accounts">service account</a> specified here. Unauthenticated users will have the app and data permissions granted to the role(s) the service account has assigned.</td></tr></tbody></table>

## Service security

<table><thead><tr><th width="276">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Unauthenticated Access</strong></td><td>Enable this option to be able to run services with unauthenticated access. A typical use case is running services from unauthenticated Apps.</td></tr><tr><td><strong>Service Account</strong></td><td>Unauthenticated access to Services will run as the <a href="../security/service-accounts">service account</a> specified here. The permissions of this unauthenticated access equals the permissions granted to the role(s) of this service account.</td></tr><tr><td><strong>Max Payload Size</strong></td><td>Override the default permitted size (in MB) for incoming POST requests to an Appfarm Service Endpoint. The default is 1 MB, and you may allow up to 50 MB.</td></tr></tbody></table>

## GraphQL security

<table><thead><tr><th width="276">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Unauthenticated Access</strong></td><td>Enable this option to be able to access the GraphQL endpoints with unauthenticated access. A typical use case is performing web requests towards the <a href="../../data-model/graphql#integration">GraphQL Endpoints</a> for querying data.</td></tr><tr><td><strong>Service Account</strong></td><td>Unauthenticated access to GraphQL will run as the <a href="../security/service-accounts">service account</a> specified here. The permissions of this unauthenticated access equals the permissions granted to the role(s) of this service account.</td></tr></tbody></table>

## User account manipulation

User accounts are global resources. Changes to user accounts in any environment will affect production. The settings below are automatically cleared every night for Development, Test and Staging to prevent unintended user changes.

<table><thead><tr><th width="281">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Allow Create User Account</strong></td><td>Enable user account creation within apps.</td></tr><tr><td><strong>Allow Update User Account</strong></td><td>Enable user account updates within apps.</td></tr><tr><td><strong>Allow Delete User Account</strong></td><td>Enable user account deletion within apps.</td></tr></tbody></table>

## Other

<table><thead><tr><th width="288">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Custom Header Tags</strong></td><td><p>Add custom <code>meta</code> and <code>script</code> tags inside the <code>&#x3C;head></code> element of your apps. This is useful when you need to add site-wide scripts, for example to implement analytics or a chatbot.</p><p></p><p>See <a href="#custom-header-tags">Custom header tags</a>.</p></td></tr><tr><td><strong>Google Analytics ID</strong></td><td><p><em><strong>Note: This feature is deprecated, and set to READ ONLY.</strong></em> </p><p><br><em>Google Analytics will not be supported as a built-in setting by Appfarm from mid-2023. From July 1st 2023, Google will replace Google Analytics (Universal Analytics, currently supported natively by Appfarm) with GA4.</em> </p><p><em>A transition guide will be distributed to those using the built-in Google Analytics ID setting.</em> </p><p></p><p>Integrate your apps with Google Analytics. Once you add an ID, the necessary scripts will be added to your apps, and page views will be automatically tracked. As with all client-side analytics, any ad-blockers or browser settings that prevent tracking may affect your reporting.<br></p><p>Note that this is only for Universal Analytics properties. Google Analytics 4 is not supported.<br><br>You may check out our guide in <a href="../../how-to/integrations/integrate-with-ga4">Integrating with Google Analytics 4</a>.</p></td></tr><tr><td><strong>.well-known Directory Entries</strong></td><td>Add publicly discoverable site-wide metadata. This is used for example, when configuring Apple Pay or <a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html">universal links</a>.</td></tr><tr><td><strong>Default App</strong></td><td><p>An unauthenticated user will be redirected to this app if they navigate to the root URL of the Appfarm Client. This setting is useful when there is a public app that acts as an entry point, such as a public web page - and you always want that App as entry point if the user is not logged in.</p><p></p><p>If a user is logged in and has access to multiple apps, the list of apps will be shown.<br><br>Please also note the setting <a href="../login#general-settings"><strong>Login Config</strong></a> -> <strong>App</strong> for defining a custom Login App.</p></td></tr></tbody></table>

### Custom header tags

Add meta tags and import custom scripts into your apps by creating custom header tags. Example use cases include additional open graph meta tags, analytics scripts, and third-party chatbots.

Custom header tags will be added to every app in the given environment. Controlling the tags at the environment level can be useful to customize or restrict analytics scripts that collect page views or track user behaviour.

Custom header tags can be used to load external javascript libraries in your apps and can be referenced when writing [functions](https://docs.appfarm.io/reference/platform-concepts/functions) or [code](https://docs.appfarm.io/library/action-nodes/run-code).

<table><thead><tr><th width="283">Setting</th><th>Description</th></tr></thead><tbody><tr><td><strong>Description</strong></td><td>A description of the header tag for easy identification.</td></tr><tr><td><strong>Tag Type</strong></td><td><p>The HTML tag to add. The options are:</p><ul><li><code>Meta</code></li><li><code>Script Content</code></li><li><code>Script URL</code></li></ul></td></tr><tr><td><strong>Name</strong></td><td><p><em>Meta tag type only.</em></p><p>The value for the name attribute of the meta tag. For example, to add a meta description tag you would enter description.</p></td></tr><tr><td><strong>Content</strong></td><td><p><em>Meta tag type only.</em></p><p>The value for the content attribute of the meta tag. For example, to add a meta description tag you would enter the actual description you wish to include.</p></td></tr><tr><td><strong>Script/Script URL</strong></td><td><p><em>Script tags only.</em></p><p>The JavaScript code or URL of a file containing JavaScript, depending on the chosen tag type.<br><br><em><strong>NB</strong>: If you add a Script URL, remember to add the domain to</em> <a href="#content-security"><em>Environment -> Content Security -> Script Sources</em></a> <em>as well!</em></p></td></tr><tr><td><strong>Async</strong></td><td><p><em>Script tags only.</em></p><p>The script should be loaded asynchronously. Find more information about the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async">async attribute on MDN</a>.</p></td></tr><tr><td><strong>Defer</strong></td><td><p><em>Script URL only.</em></p><p>The script execution should be deferred. For more information about the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-defer">defer attribute on MDN</a>.</p></td></tr><tr><td><strong>Custom attributes</strong></td><td><p>Custom attributes for the Custom header tag. Set the attribute and a value.</p><p><br><em>Example for Script URL</em><br>Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a <a href="https://developer.mozilla.org/en-US/docs/Glossary/CDN">CDN</a>) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.<br><br>You can add <code>integrity</code> and <code>crossorigin</code> as Custom attributes in order to provide the following example Script URL header tag to your app:</p><pre><code>&#x3C;script src="https://cdn.example.com/app.js"
integrity="sha384-+/M6kredJcxdsqkczBUjMLvqyHb1K/JThDXWsBVxMEeZHEaMKEOEct339VItX1zB"
crossorigin="anonymous">&#x3C;/script>
</code></pre></td></tr></tbody></table>
