Linux command
serve 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Serve current directory
serve
Serve specific directory
serve [path/to/directory]
Custom port
serve -p [8080]
Listen on all interfaces
serve -l [0.0.0.0]
Single page app mode
serve -s [path/to/spa]
Enable CORS
serve -C
说明
serve is a zero-configuration static file server for local development, created by Vercel. It serves the contents of a directory over HTTP with no setup required — just run serve in any directory to start hosting files. Single-page application (SPA) mode redirects all routes to index.html, making it suitable for testing client-side routing. CORS can be enabled with a single flag for cross-origin API testing. HTTPS is supported through SSL certificate and key files for testing secure connections locally.
参数
- -p _PORT_
- Port number.
- -l _ADDRESS_
- Listen address.
- -s
- Single page app mode.
- -C
- Enable CORS.
- -n
- Disable clipboard copy.
- -d
- Debug mode.
- --ssl-cert _FILE_
- SSL certificate.
FAQ
What is the serve command used for?
serve is a zero-configuration static file server for local development, created by Vercel. It serves the contents of a directory over HTTP with no setup required — just run serve in any directory to start hosting files. Single-page application (SPA) mode redirects all routes to index.html, making it suitable for testing client-side routing. CORS can be enabled with a single flag for cross-origin API testing. HTTPS is supported through SSL certificate and key files for testing secure connections locally.
How do I run a basic serve example?
Run `serve` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p _PORT_ do in serve?
Port number.