I’m getting the above error message from http-functions.js in the Wix backend. Does anybody have any idea what it means?
I have the same error. My setup is a little involved. I’m using a data hook like the following
export async function CustomPhotos_beforeInsert(item, context) {
item.orderNumber = 1200;
item.memberId = context.userId;
return item;
}
This entry ends up correctly in the CustomPhotos collection, but my
fetch('/account/_functions/CustomPhotos_beforeInsert', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(customData)
})
.then( (httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
} )
.then( (json) => console.log(json.someKey) )
.catch(err => console.log(err));
always comes back with Fetch did not succeed. When I inspect the developer tools, I see the a 500 and the same error as you ``x-wix-function-user-error header missing exception
.
I might be wrong, but shouldn’t the fetch be a full URL, instead of a relative one?
That should have returned a 404. So I am pretty sure it’s hitting the function.
Did you figure this out? I’m having the same issue using http-functions with authentication.login()
No, never figured it out.
I am getting this error while trying to integrate Auth0 with Wix.
I have a suspicion it might be in the following code from the http-functions.js file
import { response, ok, notFound } from 'wix-http-functions';
import { createIdp, createSp } from 'backend/create-providers.js';
import * as samlify from 'samlify';
import { authentication } from 'wix-members-backend';
const baseUrl = 'https://www.darkcheddar.com/samlwix';
export async function post_assertion(request) {
try {
const [idp, sp] = await Promise.all([createIdp(), createSp()]);
// we are not using the validation in our example, but if we dont call it, we'll get an error.
samlify.setSchemaValidator({
validate() {
return Promise.resolve('skipped');
}
});
const requestBody = await request.body.text();
const samlResponse = {
body: {
SAMLResponse: decodeURIComponent(requestBody.split('SAMLResponse=')[1])
}
}
// parse and decrypt the response
const parseResult = await sp.parseLoginResponse(idp, 'post', samlResponse);
//extract the inResponseTo Id
const inResponseTo=parseResult.extract.response.inResponseTo
//extract the email address
const email = parseResult.extract.attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'];
//create the session token to use when logging the visitor in
const sessionToken = await authentication.generateSessionToken(email);
return response({
status: 302,
headers: {
'Location': `${baseUrl}/signed-in?session=${sessionToken}&response=${inResponseTo}`
}
});
} catch (error) {
const body = await request.body.text();
console.error('Error in post_asc', error.message);
return notFound({ status: 404 })
}
}
It feels like the issue is with that last line:
return notFound({ status: 404 })
This is what I see in the editor:
TIA,
Scott
The notFound issue is something you can avoid. It’s just not a valid json looks like. using
import { ok, badRequest, notFound } from 'wix-http-functions';
const response = {
"headers": {
"Content-Type": "application/json"
}
};
response.body = {
"items": [],
"error": "Not Found"
};
return notFound(response);