forked from crowetic/commerce
* Minimal list/detail views working with Vendure * Implement useCart/useAddItem * Implement useUpdateItem & useRemoveItem * Implement useSearch * Add operations codegen, tidy up * Dummy checkout page * Implement auth/customer hooks * Use env var for Shop API url * Add some documentation * Improve error handling * Optimize preview image size * Fix accidental change * Update Vendure provider to latest changes * Vendure provider: split out gql operations, remove unused files * Update Vendure provider readme * Add local next.config to Vendure provider, update docs * Update to use demo server * Fix build errors * Use proxy for vendure api * Simplify instructions in Vendure readme * Refactor Vendure checkout api handler * Improve image quality
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
const commerce = require('./commerce.config.json')
|
|
const {
|
|
withCommerceConfig,
|
|
getProviderName,
|
|
} = require('./framework/commerce/config')
|
|
|
|
const provider = commerce.provider || getProviderName()
|
|
const isBC = provider === 'bigcommerce'
|
|
const isShopify = provider === 'shopify'
|
|
const isSwell = provider === 'swell'
|
|
const isVendure = provider === 'vendure'
|
|
|
|
module.exports = withCommerceConfig({
|
|
commerce,
|
|
i18n: {
|
|
locales: ['en-US', 'es'],
|
|
defaultLocale: 'en-US',
|
|
},
|
|
rewrites() {
|
|
return [
|
|
(isBC || isShopify || isSwell || isVendure) && {
|
|
source: '/checkout',
|
|
destination: '/api/bigcommerce/checkout',
|
|
},
|
|
// The logout is also an action so this route is not required, but it's also another way
|
|
// you can allow a logout!
|
|
isBC && {
|
|
source: '/logout',
|
|
destination: '/api/bigcommerce/customers/logout?redirect_to=/',
|
|
},
|
|
// For Vendure, rewrite the local api url to the remote (external) api url. This is required
|
|
// to make the session cookies work.
|
|
isVendure &&
|
|
process.env.NEXT_PUBLIC_VENDURE_LOCAL_URL && {
|
|
source: `${process.env.NEXT_PUBLIC_VENDURE_LOCAL_URL}/:path*`,
|
|
destination: `${process.env.NEXT_PUBLIC_VENDURE_SHOP_API_URL}/:path*`,
|
|
},
|
|
// Rewrites for /search
|
|
{
|
|
source: '/search/designers/:name',
|
|
destination: '/search',
|
|
},
|
|
{
|
|
source: '/search/designers/:name/:category',
|
|
destination: '/search',
|
|
},
|
|
{
|
|
// This rewrite will also handle `/search/designers`
|
|
source: '/search/:category',
|
|
destination: '/search',
|
|
},
|
|
].filter((x) => x)
|
|
},
|
|
})
|
|
|
|
// Don't delete this console log, useful to see the commerce config in Vercel deployments
|
|
console.log('next.config.js', JSON.stringify(module.exports, null, 2))
|