johnpapa / johnpapa/lite-server

Use lite-server to request a local json file.

Open
#125 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.3k
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### A descriptive title
I use `lite-server` and want to request a local json file `books.json`.

But it give me an error: `ERROR Error: Response with status: 404 Not Found for URL: ./app/mock/books.json`

`bs-config.json`:

```json
{
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
}
}
}

```

my component:
```ts
export class ImpureAndCachingComponent {
public bookUrl: string = './app/mock/books.json';
}
```

my directory structure:

project
* src
* app
* directives
* components
* MyComponent/index.ts <- the bookUrl is here
* mock
* books.json <- I want to request the json file
* pipes
* services
* index.html
* main.ts
* styles.css

I set the `bookUrl` relative the component file and relative the `bs-config.json` `baseDir` , both of them do not work, give me `404`.

How can I use `lite-server` to request local json file? Is it support?

### Environment
- `lite-server` version: ^2.2.2
- `nodejs` version: v6.6.0
- `npm` version: 4.1.2
- OS type/version: 10.11.6

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.