Netlify Edge - Minimal Starter Issues with axios dependency.
Environment
Netlify Edge Functions
Reproduction
Deploy this repository to the edge on netlify. https://github.com/regiolix-solutions/edge-nuxt3-storyblok-boilerplate
Describe the bug
I actually don't know if it is a Nuxt Issue or Netlify Edge Issue or Nitro. After adding @storyblok/nuxt dependency which still uses axios in the background I am not able to deploy anymore on the edge. Probably I need to write Storyblok and neither of you guys are able to fix this issue?
Additional context
No response
Logs
11:42:59 AM: TypeError: (e.adapter || Ei.adapter) is not a function
at dispatchRequest (file:///root/.netlify/edge-functions/server.js:1:328393)
at Axios$1.request (file:///root/.netlify/edge-functions/server.js:1:329798)
at Axios$1.Fi.forEach.Axios$1.<computed> [as get] (file:///root/.netlify/edge-functions/server.js:1:330138)
at Function.get (file:///root/.netlify/edge-functions/server.js:1:263057)
at X.throttledRequest (file:///root/.netlify/edge-functions/server.js:1:345354)
at a (file:///root/.netlify/edge-functions/server.js:1:335810)
at file:///root/.netlify/edge-functions/server.js:1:335951
at new Promise (<anonymous>)
at X.i [as throttle] (file:///root/.netlify/edge-functions/server.js:1:335876)
at file:///root/.netlify/edge-functions/server.js:1:344529
11:42:59 AM: [Vue warn]: Component <Anonymous> is missing template or render fun
The issue here is that the default axios adapter is undefined in the netlify-edge environment. Here's the (unminified) code:
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = requireXhr();
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
// For node use HTTP adapter
adapter = requireHttp();
}
return adapter;
}
Quite rightly, neither are defined when running in netlify-edge, so I think this is an issue that needs to be resolved upstream. Ideally storyblok would use a native fetch implementation rather than axios.