@behio/storefront-sdk 0.1.6 → 0.1.7
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/README.md +0 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,7 +121,6 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
121
121
|
return (
|
|
122
122
|
<BehioProvider
|
|
123
123
|
apiKey={process.env.NEXT_PUBLIC_BEHIO_API_KEY!} // e.g. "pk_live_6d3f255..."
|
|
124
|
-
baseUrl={process.env.NEXT_PUBLIC_BEHIO_API_URL} // optional — defaults to https://api.behio.com
|
|
125
124
|
locale="cs"
|
|
126
125
|
currency="CZK"
|
|
127
126
|
storage="cookies" // "cookies" | "localStorage" | "memory"
|
|
@@ -154,19 +153,9 @@ Set your env variables:
|
|
|
154
153
|
```bash
|
|
155
154
|
# .env.local
|
|
156
155
|
NEXT_PUBLIC_BEHIO_API_KEY=pk_live_xxxxxxxxxxxx
|
|
157
|
-
NEXT_PUBLIC_BEHIO_API_URL=https://api.behio.com # production
|
|
158
|
-
# NEXT_PUBLIC_BEHIO_API_URL=http://localhost:7007 # local dev
|
|
159
156
|
|
|
160
157
|
# For server-side (Server Actions, RSC) — NEVER expose to client
|
|
161
158
|
BEHIO_API_KEY=sk_live_xxxxxxxxxxxx
|
|
162
|
-
BEHIO_API_URL=https://api.behio.com
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**Optional:** Hide the backend URL behind a proxy. Add a Next.js rewrite in `next.config.ts` and set `baseUrl="/api"`:
|
|
166
|
-
```typescript
|
|
167
|
-
async rewrites() {
|
|
168
|
-
return [{ source: '/api/:path*', destination: 'https://api.behio.com/:path*' }];
|
|
169
|
-
}
|
|
170
159
|
```
|
|
171
160
|
|
|
172
161
|
## 2. Fetch data with hooks
|
|
@@ -212,7 +201,6 @@ export default async function ProductPage({ params }: { params: Promise<{ slug:
|
|
|
212
201
|
const { slug } = await params;
|
|
213
202
|
const shop = new BehioStorefront({
|
|
214
203
|
apiKey: process.env.BEHIO_API_KEY!,
|
|
215
|
-
baseUrl: process.env.BEHIO_API_URL,
|
|
216
204
|
});
|
|
217
205
|
const initialData = await shop.catalog.getProduct(slug);
|
|
218
206
|
return <ProductDetail slug={slug} initialData={initialData} />;
|
|
@@ -361,7 +349,6 @@ import { BehioStorefront } from '@behio/storefront-sdk';
|
|
|
361
349
|
export default async function ProductsPage() {
|
|
362
350
|
const shop = new BehioStorefront({
|
|
363
351
|
apiKey: process.env.BEHIO_API_KEY!, // ← private, server-only
|
|
364
|
-
baseUrl: process.env.BEHIO_API_URL,
|
|
365
352
|
});
|
|
366
353
|
|
|
367
354
|
const products = await shop.catalog.getProducts({ limit: 24 });
|
|
@@ -390,7 +377,6 @@ import { cookies } from 'next/headers';
|
|
|
390
377
|
function getShop() {
|
|
391
378
|
return new BehioStorefront({
|
|
392
379
|
apiKey: process.env.BEHIO_API_KEY!,
|
|
393
|
-
baseUrl: process.env.BEHIO_API_URL,
|
|
394
380
|
});
|
|
395
381
|
}
|
|
396
382
|
|
|
@@ -466,7 +452,6 @@ import { BehioStorefront } from '@behio/storefront-sdk';
|
|
|
466
452
|
|
|
467
453
|
const shop = new BehioStorefront({
|
|
468
454
|
apiKey: 'pk_live_xxx',
|
|
469
|
-
baseUrl: 'https://api.behio.com', // optional
|
|
470
455
|
locale: 'cs', // optional
|
|
471
456
|
currency: 'CZK', // optional
|
|
472
457
|
timeout: 30000, // optional — request timeout (ms)
|