create-lacspace-app 1.17.0 → 1.17.1

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -105,6 +105,9 @@ var nextConfig = () => `import { toNextHeaders } from "@lacspace/headers";
105
105
 
106
106
  /** @type {import('next').NextConfig} */
107
107
  const nextConfig = {
108
+ // Serve under a sub-path (e.g. a templates.lacspace.com/<name> demo) by setting
109
+ // NEXT_PUBLIC_BASE_PATH at build time; leave it unset for a normal standalone app.
110
+ basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
108
111
  async headers() {
109
112
  // Hardened security headers (HSTS, CSP, X-Frame-Options, \u2026) from @lacspace/headers
110
113
  return toNextHeaders();
@@ -3228,9 +3231,12 @@ export default function Page() {
3228
3231
  weight: Number((i.meta && (i.meta as Record<string, unknown>).weight) ?? 0),
3229
3232
  }));
3230
3233
  const q = quote(lines);
3234
+ // Prefix API calls so they work both standalone and under a demo sub-path
3235
+ // (basePath). router.push / <Link> already apply basePath automatically.
3236
+ const BASE = process.env.NEXT_PUBLIC_BASE_PATH || "";
3231
3237
 
3232
3238
  async function submitEsewaForm(amount: number, orderNumber: string) {
3233
- const res = await fetch("/api/pay/esewa", {
3239
+ const res = await fetch(BASE + "/api/pay/esewa", {
3234
3240
  method: "POST",
3235
3241
  headers: { "content-type": "application/json" },
3236
3242
  body: JSON.stringify({ amount, orderNumber }),
@@ -3255,7 +3261,7 @@ export default function Page() {
3255
3261
  setBusy(true);
3256
3262
  setError("");
3257
3263
  try {
3258
- const res = await fetch("/api/checkout", {
3264
+ const res = await fetch(BASE + "/api/checkout", {
3259
3265
  method: "POST",
3260
3266
  headers: { "content-type": "application/json" },
3261
3267
  body: JSON.stringify({ lines, customer: { name, email, address }, paymentMethod: method }),
@@ -3269,7 +3275,7 @@ export default function Page() {
3269
3275
  return;
3270
3276
  }
3271
3277
  if (method === "khalti") {
3272
- const pay = await fetch("/api/pay/khalti", {
3278
+ const pay = await fetch(BASE + "/api/pay/khalti", {
3273
3279
  method: "POST",
3274
3280
  headers: { "content-type": "application/json" },
3275
3281
  body: JSON.stringify({ amount: order.total, orderNumber: order.orderNumber, orderName: ${JSON.stringify(`${ctx.template.siteName} order`)}, customer: { name, email } }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lacspace-app",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "Scaffold a beautiful, production-ready Next.js app from a Lacspace template — portfolio, business, e-commerce, SaaS, blog, docs, dashboard or restaurant — pre-wired with SEO, security headers, sitemap and robots. Like create-next-app, but you start gorgeous.",
5
5
  "type": "module",
6
6
  "bin": {