Search code examples
spring-boothttp-redirectindexinglocalhost

Localhost issue trying to access index


Trying to test my deployed Springboot app through http://localhost:8080/index and it will always redirect me to http://localhost:8080/login which I don't really now what is it.

My app starts succesfully without any errors and the Controller class is as follows :

package com.spirosvatikiotis.fleetapp;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class ApplicationController {

    @GetMapping("/index")
    public String goHome() {
        return "index";
    }
}

Is this having to do with cookies?


Solution

  • You have Spring security enabled. You get redirected to /login because you don't have permission to access /index.

    Either disable security altogether or enable unauthenticated requests on /login.