Static Server
Config
in config/default.config.ts or other env config
import { ServerConfig } from '@summer-js/summer';
export const SERVER_CONFIG: ServerConfig = {
port: 8801,
static: [
{
requestPath: '/static',
destPath: 'resource',
indexFiles: ['index.html']
}
]
}
requestPath static path access root
destPath server-side access folder
indexFiles index files list
Write a simple html
<html>
<body>
Hello Summer
</body>
</html>
Put index.html to ./resource/index.html, access by browser http://127.0.0.1:8801/static/
caution
./resource is the default resource folder for summer framework destPath should be set to this folder or subfolder
Serve SPA
Summer supports serving SPA (Single Page Application) like React / Vue / Svelte app. To enable SPA redirecting feature simply add spa:ture to config.
import { ServerConfig } from '@summer-js/summer';
export const SERVER_CONFIG: ServerConfig = {
port: 8801,
static: [
{
requestPath: '/app',
destPath: 'resource',
indexFiles: ['index.html'],
spa: true
}
]
}
Put your frontend app to resource folder.