The local backend allows you to use Static CMS with a local git repository, instead of working with a live repo, regardless of backend provider. It will read and write file from your local file system inside your local git repository. You will still need to manually commit and push any files you have changed or added after completing the edits.
Configuration
Name 17362_caba1c-ae> |
Type 17362_18dc55-cf> |
Default 17362_304209-eb> |
Description 17362_ac0504-c0> |
---|---|---|---|
local_backend 17362_564962-99> |
boolean |
|
Activates the local backend for Static CMS, overriding other backend configurations 17362_09c48a-d0> |
Example
# when using the default proxy server port
local_backend: true
backend:
name: git-gateway
// when using the default proxy server port
local_backend: true,
backend: {
name: 'git-gateway',
},
Usage
- Run
npx @staticcms/proxy-server
from the root directory of the above repository.- If the default port (8081) is in use, the proxy server will not start and you will see an error message. In this case, follow these steps before proceeding.
- Start your local development server (e.g. run
gatsby develop
). - Open
http://localhost:<port>/admin
to verify that your can administer your content locally. Replace<port>
with the port of your local development server. For example Gatsby’s default port is8000
Note: @staticcms/proxy-server
runs an unauthenticated express server. As any client can send requests to the server, it should only be used for local development.
Configure Proxy Server Port
- Create a
.env
file in the project’s root folder and define the PORT you’d like the proxy server to use.
Name 17362_cb25af-67> |
Type 17362_0449a6-8f> |
Default 17362_743732-3a> |
Description 17362_8974bc-10> |
---|---|---|---|
url 17362_f5cb01-e8> |
string 17362_56b153-d8> |
|
URL for proxy server 17362_d06a97-f1> |
allowed_hosts 17362_168c0d-68> |
list of hosts 17362_3872e6-d8> |
|
Whitelist of allowed hosts when accessing the local site from a host other than ‘localhost’ or ‘127.0.0.1’ 17362_30aad9-99> |
PORT=8082
2. Update the local_backend
object in config
and specify a url
property to use your custom port number
backend:
name: git-gateway
local_backend:
# when using a custom proxy server port
url: http://localhost:8082/api/v1
# when accessing the local site from a host other than 'localhost' or '127.0.0.1'
allowed_hosts: ['192.168.0.1']
backend: {
name: 'git-gateway',
},
local_backend: {
// when using a custom proxy server port
url: 'http://localhost:8082/api/v1',
// when accessing the local site from a host other than 'localhost' or '127.0.0.1'
allowed_hosts: ['192.168.0.1'],
},