Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,090 of 9,090 pages
About the help in other languages
All help pages

Web apps, CORS and CSP

Build a browser app (PWA, single-page app) on Exponential - same origin versus another origin, the absence of CORS headers and the options around it, the site's Content Security Policy and connect-src, sessions and form…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/mobile-app-developers/offline-and-performance/web-apps-cors-and-csp.md

On this page

Web apps, CORS and CSP

This page is for developers who build an app that runs in a browser: a progressive web app, a single-page app, or a JavaScript front end on its own domain. Browsers enforce rules that native apps do not meet, and this page explains how they apply to Exponential.

Contents

  1. Same origin or another origin
  2. CORS
  3. Content Security Policy
  4. Signing in from a browser
  5. Service workers

Same origin or another origin

SetupWhat the browser allows
The app is served from the same scheme, host and port as the Exponential site (for example a design or siteaccess of the site, like the expservices sample portals)every API call, with the site's session cookie
The app is on another host (app.example.com calling www.example.com)only what CORS headers from the server allow

The sample portals of expservices (/portaljq/, /portalreact/ and others) are browser front ends built only on the remote services and served by the site itself, so they need no CORS (Remote services and apps, section 7).

CORS

Neither the REST framework (kernel/private/rest/), ezjscore nor expservices sends Access-Control-Allow-* headers, and no setting in the shipped INI files adds them. A browser app on another origin therefore cannot call the APIs directly. The options:

  1. Serve the app from the same origin, as a design of the site or under a path the web server maps to the app's files.
  2. Put a back end on the app's origin that calls Exponential server-to-server (A back end for your app). This also keeps tokens out of the browser.
  3. Add CORS headers at the web server or a proxy, for the API paths only, with an explicit list of allowed origins (never * together with credentials), and answer the OPTIONS preflight there. This is hosting work; review it as a security change (Security hardening).

Native apps (iOS, Android, desktop) and React Native's networking are not subject to CORS.

Content Security Policy

Exponential sends a Content Security Policy from site.ini [ContentSecurityPolicy]; by default it is report-only on the administration and off on the sites, and its shipped directives include connect-src 'self' (Content Security Policy). If your app is served by the site and the site enforces the policy, calls to other hosts (your back end on another domain, an analytics service) need connect-src entries, and inline scripts are not allowed: load data the way Content Security Policy for your code describes.

Signing in from a browser

  • Same origin: sign in through the site and use the session cookie. Writes to the remote services then need the form token: get it from expsession::token and send it as X-CSRF-Token and as the field ezxform_token (Writing through expservices).
  • Another origin: let the back end on the app's origin hold the credentials; do not keep tokens in localStorage (Storing secrets on devices).

Service workers

The site's own service worker, /index.js (with /sw.js as its old name), is a navigation cache for site pages: it keeps only same-origin GET navigations made without a session cookie, and only successful pages (Offline and repeat visits). It does not cache API answers for your app. A PWA that needs offline data registers its own worker with its own scope and its own cache rules, and must not take over the site's scope; agree on scopes with the site team.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x