Navigation

Static Hosting Configuration Files

app/
└── hosting/
├── config.json
├── metadata.json
└── files/
└── <files to host>

You can enable and configure static file hosting for your application in hosting/config.json.

config.json
{
"enabled": <Boolean>,
"custom_domain": "<Custom Domain Name>",
"app_default_domain": "<Default Domain Name>"
}
Field Name
Description
enabled
Boolean
If true, static hosting is enabled for your app.
custom_domain
String
The custom domain name for your application's hosted files.
app_default_domain
String
The default domain for your application's hosted files. Realm automatically sets this value and you cannot change it.

You can define metadata for any hosted file by adding an entry to hosting/metadata.json.

metadata.json
[
{
"path": "<File Resource Path>",
"attrs": [
{
"name": "<Attribute Type>",
"value": "<Attribute Value>"
},
...
]
},
...
]
Field
Description
path
String
The resource path of the file.
attrs
Array<Document>

An array of documents where each document represents a single metadata attribute. Attribute documents have the following form:

Metadata Attribute Document
{
"name": "<Attribute Type>",
"value": "<Attribute Value>"
}
Field
Description
name
String
The name of the metadata attribute. This should be one of the file metadata attributes that Realm supports.
value
String
The value of the metadata attribute.
Note

If you do not specify a Content-Type metadata attribute for a hosted file, MongoDB Realm will attempt to automatically add a Content-Type attribute to it based on the file extension.

For example, Realm would automatically add the attribute Content-Type: application/html to the file myPage.html.

Give Feedback