Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Error: Netlify CLI has terminated unexpectedly when used axios #6464

Open
Xplo8E opened this issue Mar 24, 2024 · 0 comments
Open
Labels
type: bug code to address defects in shipped code

Comments

@Xplo8E
Copy link

Xplo8E commented Mar 24, 2024

Describe the bug

when using axios to get external url in my router, netlify crashes and throws error

Screenshot 2024-03-24 at 8 54 44 AM

Steps to reproduce

use this router in server less express app:

router.post('/test-server', async (req, res) => {
    try {
        const response = await axios({
            url: 'https://example.com/'
        });
        console.log('Response status:', response.status);
        res.json({ status: response.status, data: response.data });
    } catch (error) {
        if (axios.isAxiosError) {
            console.log('Error from API', error);
            res.status(error.response.status).json({ error: error.response.statusText });
        } else {
            console.log('Internal error', error);
            res.status(500).json({ error: 'Something went wrong' });
        }
    }
});

run netlify serve --debug

after server started run:

curl -X POST http://localhost:8888/.netlify/functions/server/test-server

observed this error with axios, the server is working fine with node, but with netlify it giving this error.

Configuration

[build]
command = "npm install && npm run build"
functions = "functions"

[functions]
included_files = ["./express/.json", "./.json"]

[[redirects]]
from = "/server/*"
to = "/.netlify/functions/server/:splat"
status = 200

Environment

System:
OS: macOS 14.3.1
CPU: (8) x64 Apple M1
Memory: 17.27 MB / 8.00 GB
Shell: 5.9 - /usr/local/bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.21 - /usr/local/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Watchman: 2024.01.22.00 - /usr/local/bin/watchman
npmGlobalPackages:
netlify-cli: 17.20.1

@Xplo8E Xplo8E added the type: bug code to address defects in shipped code label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

1 participant