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:
Zaiste 2021-04-20 16:31:52 +02:00
parent bbbe270842
commit 65df8036ae
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
3 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,8 @@ function getProviderName() {
? 'shopify'
: process.env.NEXT_PUBLIC_SWELL_STORE_ID
? 'swell'
: process.env.NEXT_PUBLIC_SALEOR_API_URL
? 'saleor'
: null)
)
}

View File

@ -3,13 +3,17 @@ import fetch from './fetch'
import { API_URL } from '../../const'
import { getError } from '../../utils/handle-fetch-response'
import { getConfig } from '..'
const fetchGraphqlApi: GraphQLFetcher = async (
query: string,
{ variables } = {},
fetchOptions
) => {
const res = await fetch(API_URL, {
// FIXME @zaiste follow the bigcommerce example
const config = getConfig()
const res = await fetch(API_URL || '', {
...fetchOptions,
method: 'POST',
headers: {

View File

@ -1,3 +1,2 @@
export const API_URL = process.env.NEXT_SALEOR_API_URL
export const API_CHANNEL = process.env.NEXT_SALEOR_CHANNEL
export const API_URL = process.env.NEXT_PUBLIC_SALEOR_API_URL
export const API_CHANNEL = process.env.NEXT_PUBLIC_SALEOR_CHANNEL