# Serving Static Content

{% hint style="info" %}
Previous knowledge of [Properties](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/properties) may be required.
{% endhint %}

## Main

Mandarine allows you to configure & server static content in order to provide a straight forward way to access resources your web application may have.

## Static Content

By default, Mandarine will serve resolve static contents that are found in the folder `./src/main/resources/static`. These resources will be processed in the root of your web application url. For example, if you have a file in your static folder called `mycss.css`, and you need to access it, you would request `http://yourUrl:yourPort/mycss.css`. **Note** that files inside directories are also allowed.

## Setting Your Own Configuration

If you wish to set your own behavior for serving your static content, you can customize it by overriding the default properties in your [**properties.json**](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/properties#setting-your-own-properties)**.**

> ```typescript
> {
>     "mandarine": {
>             "resources": {
>                 "staticFolder": "./src/main/resources/static",
>                 "staticRegExpPattern": "/(.*)",
>                 "staticIndex": null,
>             }
>     }
> } 
> ```

* staticFolder
  * Folder where your static resources are located
* staticRegExpPattern
  * **Regular Expression** of URL request to match & intercept in order to serve static content.
    * By default, it is set to `/(.*)` , this means it will be intercepted in the root of your web application as described before as `/static/(.*)` would serve `http://yourUrl:yourPort/static/` for instance.
* staticIndex
  * Path of index file to be served when requesting the root of the static content (Inside `staticFolder`).

## Cors

Mandarine does not implement any CORS middleware for static content by default. This behavior must be added through the use of [Resource Handlers](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/resource-handlers) or through the use of [properties](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/properties).

#### Properties ([See Mandarine.MandarineMVC.CorsMiddlewareOption](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.CorsMiddlewareOption))

```javascript
{
    "mandarine": {
        "resources": {
            "cors": {
                "origin": "http://myweb.com",
                ...
            }
        }
    }
}
```
