Hi Shane and welcome to the community!
This suggests – however implausible it may seem – that whatever authentication method you have built into your API, it is probably not relying on those credentials when testing locally. Instead, it is more likely that it works on your local system because a security context exists salready] and is masking the failure of your API’s authentication process.
Of course, this is is purely hypothetical because I cannot see your API code.
Hi Bill, This is the API code I’m using.
const airtableHeaders = new Headers()
airtableHeaders.append(‘Content-Type’, ‘application/json’)
airtableHeaders.append(
‘Authorization’,
Bearer ${process.env.AIRTABLE_API_KEY}
)
const fieldsPrep = JSON.parse(fieldsOuter)
const raw = JSON.stringify(fieldsPrep)
const requestOptions = {
method: ‘POST’,
headers: airtableHeaders,
body: raw,
redirect: ‘follow’,
}
fetch(
https://api.airtable.com/v0/app1234567890/${airtableFormId}
,
requestOptions
)
.then(response => response.text())
.then(result => {
const returnedData = JSON.parse(result)
if (returnedData.createdTime) {
setSubmitted(true)
}
})
.catch(error => handleError(error))
Hi Bill, This is the API code I’m using.
const airtableHeaders = new Headers()
airtableHeaders.append(‘Content-Type’, ‘application/json’)
airtableHeaders.append(
‘Authorization’,
Bearer ${process.env.AIRTABLE_API_KEY}
)
const fieldsPrep = JSON.parse(fieldsOuter)
const raw = JSON.stringify(fieldsPrep)
const requestOptions = {
method: ‘POST’,
headers: airtableHeaders,
body: raw,
redirect: ‘follow’,
}
fetch(
https://api.airtable.com/v0/app1234567890/${airtableFormId}
,
requestOptions
)
.then(response => response.text())
.then(result => {
const returnedData = JSON.parse(result)
if (returnedData.createdTime) {
setSubmitted(true)
}
})
.catch(error => handleError(error))
Have you set this variable with your api key on the server?
If you are pulling code from a repository, the code setting the api key probably wasn’t in the repository for security reasons.