nestjs / serve-static

Serve static websites (SPA's) using Nest framework (node.js) šŸ„¦

Home Page:https://nestjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index not working in serveStaticOptions

norikkozmelj opened this issue Ā· comments

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior


ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', '.well-known/apple-app-site-association'),
      serveStaticOptions: { index: ['index.json'] },
}),

The code above does still not work if index.html is not available.

Expected behavior

I want to serve the JSON file instead of HTML.

What is the motivation / use case for changing the behavior?

I need apple app site association file for the deep-linking iOS app with my backend.

Environment


Nest version: 6.11.11

 
For Tooling issues:
- Node version: 10.12.18  
- Platform: Linux 

You shouldn't use serve-static module for this. This package is intended to minimize & simplify the boilerplate code needed for serving SPA from Nest.

Instead, you should rather look at the useStaticAssets() method which gives more control & flexibility. You can find some usage examples here https://docs.nestjs.com/techniques/mvc