Open Ibabalola opened 4 years ago
I have same problem
I thought I hit the same issue recently while using Crumb in restful: true
mode. Then realised I wasn't passing the csrf token header in the request & all was good.
Here is my proxy route:
server.route({
method: ['*'],
path: '/proxy/{path*}',
handler: {
proxy: {
passThrough: true,
mapUri: (request) => {
return {
uri: urlJoin(options.url, request.path, request.url.search),
};
},
async onResponse(err, res, request, h) {
if (err) {
return h.response(err);
}
const response = h.response(res);
response.headers = res.headers;
response.header('X-CSRF-Token', request.plugins.crumb); // add csrf token header for restful crumb usage
return response;
},
},
},
Hope that's of help to someone.
p.s. I noticed @Ibabalola mapUri
was returning an undefined headers
which could have been causing the 500.
You need to set localStatePassThrough: true
on the proxy route
Support plan
Context
What are you trying to achieve or the steps to reproduce?
The front end is passing correctly the crumb token, the crumb token is stored inside the cookie.
Crumb plugin registry:
The proxy sent down the date as a Stream format; In the below code because the content is of type
Stream
the request is forbidden.This is my proxy
Tried to change the option to be payload: 'data' with no luck
What was the result you got?
500 Internal Server Error
What result did you expect?
200 OK