Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
From the frontend app implementation call a SDK endpoint through the middleware that calls external API that returns 401 status code response. The middleware fails with generic 500 error and doesn't propagate the original error and status code.
Describe the bug
Middleware doesn't propagate the original status code and error messages coming from the target API.
api-client fails with: ServerError: Response not successful: Received status code 401
middleware fails with: ServerError: Response not successful. Please, check server logs for more details.
Additional context
No response
Logs
Server
[Middleware] [Network error]: ServerError: Response not successful: Received status code 401
[Middleware]
[Middleware] ERROR Response not successful: Received status code 401
[Middleware]
[Middleware] at new ApolloError (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:2943:28)
[Middleware] at /Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:8479:19
[Middleware] at both (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:2329:53)
[Middleware] at /Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:2322:72
[Middleware] at new Promise (<anonymous>)
[Middleware] at Object.then (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:2322:24)
[Middleware] at Object.error (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:2331:26)
[Middleware] at notifySubscription (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:1744:18)
[Middleware] at onNotify (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:1783:3)
[Middleware] at SubscriptionObserver.error (/Users/bojanche/dev/frontend/storefront-sdk/packages/api-client/server/index.js:1836:5)
Browser:
```sh
warn2 @ chunk-QWDWOYML.js:1449
logError @ chunk-QWDWOYML.js:1623
handleError @ chunk-QWDWOYML.js:1615
(anonymous) @ chunk-QWDWOYML.js:1576
Promise.catch (async)
callWithAsyncErrorHandling @ chunk-QWDWOYML.js:1575
invoker @ chunk-QWDWOYML.js:9397
index.es.js:71 Uncaught (in promise) SDKError: Request failed with status code 500
at handleError (index.es.js:71:12)
at Proxy.<anonymous> (index.es.js:254:27)
at async callEndpoint (bundleDetail.vue:36:20)
handleError @ index.es.js:71
(anonymous) @ index.es.js:254
Promise.catch (async)
callWithAsyncErrorHandling @ chunk-QWDWOYML.js:1575
invoker @ chunk-QWDWOYML.js:9397
Environment
MacOS Node v20
@vue-storefront/middleware
: 3.5.1@vue-storefront/sdk
: 1.1.2Reproduction
From the frontend app implementation call a SDK endpoint through the middleware that calls external API that returns 401 status code response. The middleware fails with generic 500 error and doesn't propagate the original error and status code.
Describe the bug
Middleware doesn't propagate the original status code and error messages coming from the target API.
api-client
fails with:ServerError: Response not successful: Received status code 401
middleware fails with:
ServerError: Response not successful. Please, check server logs for more details.
Additional context
No response
Logs