Skip to content

Commit b57177e

Browse files
docs(component): update readme for serving static files (#94)
update readme for serving static files GH-51
1 parent 7c6fc27 commit b57177e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,30 @@ export const enum PermissionKey {
267267
DeleteAudit = 'DeleteAudit',
268268
}
269269
```
270+
- Serving the static files:
271+
272+
Authorization configuration binding sets up paths that can be accessed without any authorization checks, allowing static files to be served directly from the root URL of the application.The allowAlwaysPaths property is used to define these paths for the files in public directory i.e for a test.html file in public directory ,one can provide its path as follows:
273+
274+
```
275+
this.bind(AuthorizationBindings.CONFIG).to({
276+
allowAlwaysPaths: ['/explorer','/test.html'],
277+
});
278+
```
279+
280+
To set up the public directory as a static,one can add the following in application.ts file.
281+
282+
```
283+
this.static('/', path.join(__dirname, '../public'));
284+
285+
```
286+
If ,in case the file is in some other folder then `app.static()` can be called multiple times to configure the app to serve static assets from different directories.
287+
288+
```
289+
this.static('/', path.join(__dirname, '../public'));
290+
this.static('/downloads', path.join(__dirname, '../downloads'));
291+
292+
```
293+
For more details,refer [here](https://loopback.io/doc/en/lb4/Serving-static-files.html#:~:text=One%20of%20the%20basic%20requirements,the%20API%20are%20explained%20below.)
270294

271295
# Extension enhancement using CASBIN authorisation
272296

@@ -527,6 +551,7 @@ async create(@requestBody() role: Role): Promise<Role> {
527551
}
528552
```
529553

554+
530555
## Feedback
531556

532557
If you've noticed a bug or have a question or have a feature request, [search the issue tracker](https://github.com/sourcefuse/loopback4-authorization/issues) to see if someone else in the community has already created a ticket.

0 commit comments

Comments
 (0)