When using bunx npm run backend
29 | const host = HOST || 'localhost';
30 | const trusted_proxy = Number(TRUST_PROXY) || 1; /* trust first proxy by default */
31 |
32 | const startServer = async () => {
33 | if (typeof Bun !== 'undefined') {
34 | axios.defaults.headers.common['Accept-Encoding'] = 'gzip';
^
TypeError: undefined is not an object (evaluating 'axios.defaults.headers')
at <anonymous> (/Users/lwragg002/repos/chatpwc-pro/genai-chat-pro/api/server/index.js:34:11)
at startServer (/Users/lwragg002/repos/chatpwc-pro/genai-chat-pro/api/server/index.js:32:21)
at <anonymous> (/Users/lwragg002/repos/chatpwc-pro/genai-chat-pro/api/server/index.js:146:1)
updating
if (typeof Bun !== 'undefined') {
axios.default.defaults.headers.common['Accept-Encoding'] = 'gzip';
}
to
if (typeof Bun !== 'undefined') {
axios.default.headers.common['Accept-Encoding'] = 'gzip';
}
Allows the server to start, but get other errors after that:
{"level":"error","message":"Failed to fetch models from OpenAI API An error occurred while setting up the request: axios.get is not a function. (In 'axios.get(url.toString(), options)', 'axios.get' is undefined)","timestamp":"2025-05-05T01:08:15.774Z"}
const res = await axios.default.get(url.toString(), options); fixes the second issue, but this looks to be because of bad axios import to begin with.
import { default as axios } from 'axios'; as suggested on npm page doesnt work either, gets stuck on cookie-parser error after that