mirror of
https://github.com/typicode/json-server.git
synced 2025-07-24 10:29:27 +08:00
fix: public
This commit is contained in:
1
public/test.html
Normal file
1
public/test.html
Normal file
@ -0,0 +1 @@
|
||||
<!-- Testing automatic serving of files from the 'public/' directory -->
|
@ -67,7 +67,7 @@ await test('createApp', async (t) => {
|
||||
const arr: Test[] = [
|
||||
// Static
|
||||
{ method: 'GET', url: '/', statusCode: 200 },
|
||||
{ method: 'GET', url: '/output.css', statusCode: 200 },
|
||||
{ method: 'GET', url: '/test.html', statusCode: 200 },
|
||||
{ method: 'GET', url: `/${file}`, statusCode: 200 },
|
||||
|
||||
// CORS
|
||||
|
@ -31,7 +31,7 @@ export function createApp(db: Low<Data>, options: AppOptions = {}) {
|
||||
const app = new App()
|
||||
|
||||
// Static files
|
||||
app.use(sirv(join(__dirname, '../public'), { dev: !isProduction }))
|
||||
app.use(sirv('public', { dev: !isProduction }))
|
||||
options.static
|
||||
?.map((path) => (isAbsolute(path) ? path : join(process.cwd(), path)))
|
||||
.forEach((dir) => app.use(sirv(dir, { dev: !isProduction })))
|
||||
|
Reference in New Issue
Block a user