mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
fix: client/server pecularities for env visibility
Must prefix with `NEXT_PUBLIC_` so that the API URL is visible on the client
This commit is contained in:
parent
bbbe270842
commit
65df8036ae
@ -18,6 +18,8 @@ function getProviderName() {
|
|||||||
? 'shopify'
|
? 'shopify'
|
||||||
: process.env.NEXT_PUBLIC_SWELL_STORE_ID
|
: process.env.NEXT_PUBLIC_SWELL_STORE_ID
|
||||||
? 'swell'
|
? 'swell'
|
||||||
|
: process.env.NEXT_PUBLIC_SALEOR_API_URL
|
||||||
|
? 'saleor'
|
||||||
: null)
|
: null)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,17 @@ import fetch from './fetch'
|
|||||||
|
|
||||||
import { API_URL } from '../../const'
|
import { API_URL } from '../../const'
|
||||||
import { getError } from '../../utils/handle-fetch-response'
|
import { getError } from '../../utils/handle-fetch-response'
|
||||||
|
import { getConfig } from '..'
|
||||||
|
|
||||||
const fetchGraphqlApi: GraphQLFetcher = async (
|
const fetchGraphqlApi: GraphQLFetcher = async (
|
||||||
query: string,
|
query: string,
|
||||||
{ variables } = {},
|
{ variables } = {},
|
||||||
fetchOptions
|
fetchOptions
|
||||||
) => {
|
) => {
|
||||||
const res = await fetch(API_URL, {
|
// FIXME @zaiste follow the bigcommerce example
|
||||||
|
const config = getConfig()
|
||||||
|
|
||||||
|
const res = await fetch(API_URL || '', {
|
||||||
...fetchOptions,
|
...fetchOptions,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
export const API_URL = process.env.NEXT_SALEOR_API_URL
|
export const API_URL = process.env.NEXT_PUBLIC_SALEOR_API_URL
|
||||||
|
export const API_CHANNEL = process.env.NEXT_PUBLIC_SALEOR_CHANNEL
|
||||||
export const API_CHANNEL = process.env.NEXT_SALEOR_CHANNEL
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user