Deployment of multi-page web app with minikube

10/23/2018

Good afternoon,

I'm trying to use minikube in order to deploy a multi-page nodejs-mongoDB web app. I have created my app, I have dockerized it and now I'm trying to deploy it locally using minikube. When I execute minikube minikube service my-app --url in a Unix shell I obtain an IP. Putting the IP in the browser I obtain the index page but trying to use the button to switch to another page the browser doesn't switch. I am sure the app is correct because executing it locally I obtain what I want but I cannot understand why this fails in minikube. I am new and I am not an expert. Can anyone help me?

Here the HTML code for the index page :

<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body>
    <h1><%= title %></h1>
    <p>Welcome to <%= title %></p>

    <form method="get" action="./insert/item">
      <input type="submit" value="Insert">
    </form>

  </body>
</html>

Here the server side of the index page:

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/insert/item', (req, res) => {
  res.redirect('/insert');
});

module.exports = router;
-- Anto
docker
javascript
kubernetes
minikube
node.js

1 Answer

10/23/2018

I guess you have a JS error related to CORS security (https://developer.mozilla.org/fr/docs/Web/HTTP/CORS). This is preventing one website to interact with another one through JS.

You can check that by using Developer tools in :

Your service might be good fo running locally but not on a remote website that the k8s service ip is presenting you.

-- webofmars
Source: StackOverflow