2021-02-25 16:39:01 -05:00
|
|
|
const commerce = require('./commerce.config.json')
|
2021-03-29 17:03:45 -06:00
|
|
|
const {
|
|
|
|
withCommerceConfig,
|
|
|
|
getProviderName,
|
|
|
|
} = require('./framework/commerce/config')
|
2021-02-24 21:55:45 -05:00
|
|
|
|
2021-03-29 17:03:45 -06:00
|
|
|
const provider = commerce.provider || getProviderName()
|
|
|
|
const isBC = provider === 'bigcommerce'
|
|
|
|
const isShopify = provider === 'shopify'
|
2021-06-10 08:46:28 +02:00
|
|
|
const isSaleor = provider === 'saleor'
|
2021-05-12 11:23:04 -05:00
|
|
|
const isSwell = provider === 'swell'
|
2021-05-27 23:06:56 +02:00
|
|
|
const isVendure = provider === 'vendure'
|
2021-02-24 21:55:45 -05:00
|
|
|
|
|
|
|
module.exports = withCommerceConfig({
|
2021-06-10 08:46:28 +02:00
|
|
|
future: {
|
|
|
|
webpack5: true,
|
|
|
|
},
|
2021-02-24 21:55:45 -05:00
|
|
|
commerce,
|
|
|
|
i18n: {
|
|
|
|
locales: ['en-US', 'es'],
|
|
|
|
defaultLocale: 'en-US',
|
|
|
|
},
|
|
|
|
rewrites() {
|
|
|
|
return [
|
2021-05-27 23:06:56 +02:00
|
|
|
(isBC || isShopify || isSwell || isVendure) && {
|
2021-02-24 21:55:45 -05:00
|
|
|
source: '/checkout',
|
2021-06-01 03:18:10 -05:00
|
|
|
destination: '/api/checkout',
|
2021-02-24 21:55:45 -05:00
|
|
|
},
|
|
|
|
// 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',
|
2021-06-01 03:18:10 -05:00
|
|
|
destination: '/api/logout?redirect_to=/',
|
2021-02-24 21:55:45 -05:00
|
|
|
},
|
2021-05-27 23:06:56 +02:00
|
|
|
// 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*`,
|
|
|
|
},
|
2021-05-31 23:32:10 -03:00
|
|
|
].filter(Boolean)
|
2021-02-24 21:55:45 -05:00
|
|
|
},
|
|
|
|
})
|
2021-03-29 17:03:45 -06:00
|
|
|
|
|
|
|
// 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))
|