FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Issue with POST to /oauth2/token from container inside K8s

    Scheduled Pinned Locked Moved Unsolved
    Q&A
    2
    2
    355
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      vince
      last edited by

      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);
          });
      
      });
      
      danD 1 Reply Last reply Reply Quote 0
      • danD
        dan @vince
        last edited by

        @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?

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • First post
          Last post