Home > front end >  Error occurred while trying to proxy request /api/v1/mega/building from localhost:4200 to http://loc
Error occurred while trying to proxy request /api/v1/mega/building from localhost:4200 to http://loc

Time:12-28

it's my first time using Java backend and angular front end. I'm trying to build and run this project but I'm having this error: "[HPM] Error occurred while trying to proxy request /api/v1/mega/building from localhost:4200 to http://localhost:8080 (ECONNREFUSED)"

I ran .\gradlew.bat build to build the Java Application and the run npm install and npm run start on the angular and node js code..

Do I have to start the Java server in some way after building the project?

Here is my code:

main.java


import com.nortal.mega.persistence.BuildingRepository;
import com.nortal.mega.persistence.entity.BuildingDbo;
import lombok.AllArgsConstructor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;

import java.util.Arrays;

@AllArgsConstructor
@SpringBootApplication
public class Main {

    private final BuildingRepository buildingRepository;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

proxy.conf.json I have tried changing the target to 127.0.0.1, [::] all to no avail

    "/api/*": {
        "target": "http://localhost:8080",
        "secure": false,
        "loglevel": "debug"
    }
}

CodePudding user response:

Sounds like your backend is just not running. To start a spring boot application:

./gradlew bootRun

from the root of your java application

edit: Looks like you are on Windows, so it would be something like

.\gradlew.bat bootRun
  • Related