create-mantiq 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mantiq",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "description": "Scaffold a new MantiqJS application",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -4,7 +4,52 @@ import tailwindcss from '@tailwindcss/vite'
4
4
  import path from 'path'
5
5
 
6
6
  export default defineConfig({
7
- plugins: [react(), tailwindcss()],
7
+ plugins: [
8
+ react(),
9
+ tailwindcss(),
10
+ // Proxy non-asset requests to the Mantiq backend in dev mode
11
+ // so session cookies and CSRF tokens work on the same origin
12
+ {
13
+ name: 'mantiq-proxy',
14
+ configureServer(server) {
15
+ server.middlewares.use((req, res, next) => {
16
+ // Let Vite handle its own files: HMR, source files, node_modules
17
+ const viteOwned = req.url?.startsWith('/@') ||
18
+ req.url?.startsWith('/src/') ||
19
+ req.url?.startsWith('/node_modules/') ||
20
+ req.url?.includes('?import') ||
21
+ req.url?.includes('?t=')
22
+
23
+ if (viteOwned) return next()
24
+
25
+ // For HTML page navigations (SPA), let Vite serve index.html
26
+ const accept = req.headers.accept ?? ''
27
+ if (req.method === 'GET' && accept.includes('text/html')) return next()
28
+
29
+ // Everything else (POST, API calls, etc.) → proxy to backend
30
+ const backend = `http://localhost:${process.env.APP_PORT ?? 3000}`
31
+ import('node:http').then(({ request }) => {
32
+ const proxyReq = request(
33
+ `${backend}${req.url}`,
34
+ {
35
+ method: req.method,
36
+ headers: req.headers,
37
+ },
38
+ (proxyRes) => {
39
+ res.writeHead(proxyRes.statusCode ?? 500, proxyRes.headers)
40
+ proxyRes.pipe(res)
41
+ },
42
+ )
43
+ proxyReq.on('error', () => {
44
+ res.writeHead(502)
45
+ res.end('Backend not running. Start with: bun run index.ts')
46
+ })
47
+ req.pipe(proxyReq)
48
+ })
49
+ })
50
+ },
51
+ },
52
+ ],
8
53
  publicDir: false,
9
54
  resolve: {
10
55
  alias: {
@@ -4,7 +4,44 @@ import tailwindcss from '@tailwindcss/vite'
4
4
  import path from 'path'
5
5
 
6
6
  export default defineConfig({
7
- plugins: [svelte(), tailwindcss()],
7
+ plugins: [
8
+ svelte(),
9
+ tailwindcss(),
10
+ {
11
+ name: 'mantiq-proxy',
12
+ configureServer(server) {
13
+ server.middlewares.use((req, res, next) => {
14
+ const viteOwned = req.url?.startsWith('/@') ||
15
+ req.url?.startsWith('/src/') ||
16
+ req.url?.startsWith('/node_modules/') ||
17
+ req.url?.includes('?import') ||
18
+ req.url?.includes('?t=')
19
+
20
+ if (viteOwned) return next()
21
+
22
+ const accept = req.headers.accept ?? ''
23
+ if (req.method === 'GET' && accept.includes('text/html')) return next()
24
+
25
+ const backend = `http://localhost:${process.env.APP_PORT ?? 3000}`
26
+ import('node:http').then(({ request }) => {
27
+ const proxyReq = request(
28
+ `${backend}${req.url}`,
29
+ { method: req.method, headers: req.headers },
30
+ (proxyRes) => {
31
+ res.writeHead(proxyRes.statusCode ?? 500, proxyRes.headers)
32
+ proxyRes.pipe(res)
33
+ },
34
+ )
35
+ proxyReq.on('error', () => {
36
+ res.writeHead(502)
37
+ res.end('Backend not running. Start with: bun run index.ts')
38
+ })
39
+ req.pipe(proxyReq)
40
+ })
41
+ })
42
+ },
43
+ },
44
+ ],
8
45
  publicDir: false,
9
46
  resolve: {
10
47
  alias: {
@@ -4,7 +4,44 @@ import tailwindcss from '@tailwindcss/vite'
4
4
  import path from 'path'
5
5
 
6
6
  export default defineConfig({
7
- plugins: [vue(), tailwindcss()],
7
+ plugins: [
8
+ vue(),
9
+ tailwindcss(),
10
+ {
11
+ name: 'mantiq-proxy',
12
+ configureServer(server) {
13
+ server.middlewares.use((req, res, next) => {
14
+ const viteOwned = req.url?.startsWith('/@') ||
15
+ req.url?.startsWith('/src/') ||
16
+ req.url?.startsWith('/node_modules/') ||
17
+ req.url?.includes('?import') ||
18
+ req.url?.includes('?t=')
19
+
20
+ if (viteOwned) return next()
21
+
22
+ const accept = req.headers.accept ?? ''
23
+ if (req.method === 'GET' && accept.includes('text/html')) return next()
24
+
25
+ const backend = `http://localhost:${process.env.APP_PORT ?? 3000}`
26
+ import('node:http').then(({ request }) => {
27
+ const proxyReq = request(
28
+ `${backend}${req.url}`,
29
+ { method: req.method, headers: req.headers },
30
+ (proxyRes) => {
31
+ res.writeHead(proxyRes.statusCode ?? 500, proxyRes.headers)
32
+ proxyRes.pipe(res)
33
+ },
34
+ )
35
+ proxyReq.on('error', () => {
36
+ res.writeHead(502)
37
+ res.end('Backend not running. Start with: bun run index.ts')
38
+ })
39
+ req.pipe(proxyReq)
40
+ })
41
+ })
42
+ },
43
+ },
44
+ ],
8
45
  publicDir: false,
9
46
  resolve: {
10
47
  alias: {