@@ -8,6 +8,7 @@ HTTP Server adapter for ObjectStack using Hono.
88- ** Fast** : Built on Hono, a high-performance web framework.
99- ** Full Protocol Support** : Automatically provides all ObjectStack Runtime endpoints (Auth, Data, Metadata, etc.).
1010- ** Middleware** : Supports standard Hono middleware.
11+ - ** Wildcard CORS** : Supports wildcard patterns in CORS origins (compatible with better-auth).
1112
1213## Usage
1314
@@ -18,7 +19,7 @@ import { HonoServerPlugin } from '@objectstack/plugin-hono-server';
1819const kernel = new ObjectKernel ();
1920
2021// Register the server plugin
21- kernel .use (new HonoServerPlugin ({
22+ kernel .use (new HonoServerPlugin ({
2223 port: 3000 ,
2324 restConfig: {
2425 api: {
@@ -30,6 +31,75 @@ kernel.use(new HonoServerPlugin({
3031await kernel .start ();
3132```
3233
34+ ## CORS Configuration
35+
36+ The Hono server plugin supports flexible CORS configuration with wildcard pattern matching.
37+
38+ ### Basic CORS
39+
40+ ``` typescript
41+ kernel .use (new HonoServerPlugin ({
42+ port: 3000 ,
43+ cors: {
44+ origins: [' https://app.example.com' ],
45+ credentials: true
46+ }
47+ }));
48+ ```
49+
50+ ### Wildcard Patterns (better-auth compatible)
51+
52+ ``` typescript
53+ // Subdomain wildcards
54+ kernel .use (new HonoServerPlugin ({
55+ cors: {
56+ origins: [' https://*.objectui.org' , ' https://*.objectstack.ai' ],
57+ credentials: true
58+ }
59+ }));
60+
61+ // Port wildcards (useful for development)
62+ kernel .use (new HonoServerPlugin ({
63+ cors: {
64+ origins: ' http://localhost:*'
65+ }
66+ }));
67+
68+ // Comma-separated patterns
69+ kernel .use (new HonoServerPlugin ({
70+ cors: {
71+ origins: ' https://*.objectui.org,https://*.objectstack.ai,http://localhost:*'
72+ }
73+ }));
74+ ```
75+
76+ ### Environment Variables
77+
78+ CORS can also be configured via environment variables:
79+
80+ ``` bash
81+ # Single origin
82+ CORS_ORIGIN=https://app.example.com
83+
84+ # Wildcard patterns (comma-separated)
85+ CORS_ORIGIN=https://* .objectui.org,https://* .objectstack.ai
86+
87+ # Disable CORS
88+ CORS_ENABLED=false
89+
90+ # Additional options
91+ CORS_CREDENTIALS=true
92+ CORS_MAX_AGE=86400
93+ ```
94+
95+ ### Disable CORS
96+
97+ ``` typescript
98+ kernel .use (new HonoServerPlugin ({
99+ cors: false // Completely disable CORS
100+ }));
101+ ```
102+
33103## Architecture
34104
35105This plugin wraps ` @objectstack/hono ` to provide a turnkey HTTP server solution for the Runtime. It binds the standard ` HttpDispatcher ` to a Hono application and starts listening on the configured port.
0 commit comments