Issue with POST to /oauth2/token from container inside K8s
-
I'm having some issues with my nodejs backend making POST requests to Fusionauths /oauth2/token endpoint when the the nodejs app is running Kubernetes.
I used the fusionauth provided example for react with a node backend as a template and updated it a bit. It works great when I run it locally on my dev machine but when I run the nodejs backend in a Kubernetes pod I'm getting the following error:
"Client network socket disconnected before secure TLS connection was established"Below is my callback code
const express = require('express'); const router = express.Router(); const axios = require('axios'); router.get('/oauth-callback', async (req, res) => { const uri = `${process.env.FUSION_AUTH_URI}/oauth2/token`; const form = new FormData(); form.append('client_id', process.env.FUSION_AUTH_CLIENT_ID); form.append('client_secret', process.env.FUSION_AUTH_CLIENT_SECRET) form.append('code', req.query.code); form.append('grant_type', 'authorization_code'); form.append('redirect_uri', process.env.FUSION_AUTH_REDIRECT_URI); axios.post(uri, form, { headers: form.getHeaders() }) .then((response) => { req.session.token = response.data.access_token; res.redirect(process.env.FUSION_AUTH_LOGGED_IN_URI); }).catch((error) => { console.error("error", JSON.stringify(error)); res.redirect(process.env.FUSION_AUTH_LOGGED_IN_URI); }); });
-
@vince Hmmm. That sounds like a network connectivity issue. Googling for
Client network socket disconnected before secure TLS connection was established
shows that a lot of folks have proxy issues.Can you run curl on the same host and see if you can get to FusionAuth successfully?