Are you experiencing ERR_CONNECTION_REFUSED on both Chrome and Firefox?

I'm currently working on an Angular2 website. Everything is running smoothly in Internet Explorer, but I am encountering an ERR_CONNECTION_REFUSED error when trying to access it from Chrome and Firefox.

Here is the code snippet:

This is the content of my home.component.html:

<div class="log_wrap">
          <div class="log_img"></div>
          <ul class="log_list">
            <li>USER ID<br>
                <input class="log_input" placeholder="Login ID" id="LoginID" type="text">
            </li>
            <li>PASSWORD<br>
                <input class="log_input" placeholder="*******" id="password" type="password">
            </li>

            <li>
              <input type="button" class="reset_but" value="Reset"/>
                <input type="button" class="log_but" value="Login" (click)="login_btnClick()"/>
            </li>
          </ul>
        </div>

Now moving on to my home.component.ts:

export class HomeComponent {
    homes: IHome[];
    home: IHome;
    msg: string;
    indLoading: boolean = false;
    constructor(private fb: FormBuilder, private _homeService: HomeService, private router: Router) { }

    login_btnClick() {
        var Domain = "sgl";
        var Username = ((document.getElementById("LoginID") as HTMLInputElement).value);
        var Password = ((document.getElementById("password") as HTMLInputElement).value);
        this._homeService.get(Global.BASE_USER_ENDPOINT + '/ValidateEmployee?Domain=' + Domain + '&Username=' + Username + '&Password=' + Password)
            .do(data => sessionStorage.setItem('session', Username))
            .subscribe(homes => {
                this.homes = homes;
                this.indLoading = false;
                var NT = sessionStorage.getItem('session');
                //this.router.navigateByUrl('/user');
                this.EmpDetails();
            },
            error => this.msg = <any>error);
    }
}

This is what's included in my home.ts:

export interface IHome {
    EmpName: string,
    EmpNumber: string,
    EmailId: string,
    Id: number,
    FirstName: string,
    LastName: string,
    Gender: string
}

And here is the contents of home.service.ts:

export class HomeService {
    constructor(private _http: Http) { }
    get(url: string): Observable<any> {
        return this._http.get(url)
            .map((response: Response) => <any>response.json())
            .catch(this.handleError);
    }

The code functions flawlessly in IE, however it fails to work in Google Chrome and Firefox with an ERR_CONNECTION_REFUSED error message.

Lastly, I have provided a glimpse of my angular-cli.json file: angular-cli.json

 {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "project": {
        "name": "i-roz-ui"
      },
      "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"
          ],
          "index": "index.html",
          "main": "main.ts",
          "polyfills": "polyfills.ts",
          "test": "test.ts",
          "tsconfig": "tsconfig.app.json",
          "testTsconfig": "tsconfig.spec.json",
          "prefix": "app",
          "styles": [
            "styles.css"
          ],
          "scripts": [],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ],
      "e2e": {
        "protractor": {
          "config": "./protractor.conf.js"
        }
      },
      "lint": [
        {
          "project": "src/tsconfig.app.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "src/tsconfig.spec.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "e2e/tsconfig.e2e.json",
          "exclude": "**/node_modules/**"
        }
      ],
      "test": {
        "karma": {
          "config": "./karma.conf.js"
        }
      },
      "defaults": {
        "styleExt": "css",
        "class": {
          "spec": false
        },
        "component": {
          "spec": false
        },
        "directive": {
          "spec": false
        },
        "guard": {
          "spec": false
        },
        "module": {
          "spec": false
        },
        "pipe": {
          "spec": false
        },
        "service": {
          "spec": false
        }
      }
    }

Answer №1

For better performance, consider launching Chrome with the additional parameter: --disable-web-security

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

ngrx/effects - Sequential actions triggered by previous actions

Before retrieving data from an API, it is crucial to verify if a token is already stored and whether it remains valid. Should the token be missing or expired, a new one must be obtained from the API, with the requirement of waiting for the GET_TOKEN_SUCCES ...

Guide on stubbing Google gapi global variable in component tests with Karma

I am currently facing a challenge in setting up tests for a service in my Angular 4 project that utilizes Google gapi. The issue arises from the fact that the variable is globally declared but not mocked, leading to an error when running the tests: Refe ...

Sharing Data Across Multiple Windows in Angular 2 Using a Singleton List

My multiplayer game involves adding new players to a single game room lobby, which is essentially a list of current players. How can I update this list for all connected players when new ones join? I implemented a service and included it in the providers ...

Creating an autofocus feature using Angular 7 upon clicking a button

Within a table in my application, I have text boxes that are initially disabled and then enabled after clicking an edit button. Everything is working smoothly so far, but I am trying to set the autofocus to the first textbox of the first row when the edi ...

Retrieving coordinates from an API and displaying them on a Google Maps interface

I have a task where I need to retrieve location coordinates from an API and display the area on a Google Map embedded within my webpage using Angular 2. Here is what I have accomplished so far: MapComponent.ts import { Component, OnInit } from '@angu ...

Dealing with type errors involving null values when using interfaces in Typescript

I encountered an issue related to the error property within the defaultState constant: interface AuthState<T = any> { auth: T; error: null | Error; loading: boolean; } export const defaultState: { auth: null | AuthState } = { auth: null, e ...

Function in nodejs throwing an error: Return type missing

I am facing an issue with this code snippet while trying to compile the application. public async test(options?: { engine?: Config }): Promise<any> { const hostel = new Service({ list: this.servicesList, createService ...

Certain Array properties cause Array methods to generate errors

I am working with an Array prop in my component's props that is defined like this props: { datasetsList: { type: Array as PropType<Array<ParallelDataset>>, required: false } }, Within the setup() method of my component, I have ...

Updating a one-to-one relationship in TypeORM with Node.js and TypeScript can be achieved by following these steps

I am working with two entities, one is called Filter and the other is Dataset. They have a one-to-one relationship. I need help in updating the Filter entity based on Dataset using Repository with promises. The code is written in a file named node.ts. Th ...

Is error propagation from nested Promise to parent Promise not working properly in Node.js?

I'm currently working on a Node.js/TypeScript API with Express. Below is a snippet from my get method where I encountered an error in the format function. The error is caught by the promise, but it doesn't propagate to the parent promise after th ...

A comprehensive guide on implementing form array validations in Angular 8

I am currently using the formArray feature to dynamically display data in a table, which is working perfectly. However, I am facing difficulty in applying the required field validation for this table. My goal is to validate the table so that no null entry ...

What methods are available to maximize the capabilities of Node's stream?

I've been attempting to develop a method for Readable Stream, but I quickly reached a point where I couldn't proceed any further. import * as stream from 'stream' //results in: Property 'asdasas' does not exist on type ' ...

Is there a way to toggle glyphicons in Angular 2 while also triggering their functions? Maybe using *ngIf?

I am working on a feature to add items to favorites in my Angular 2 app. The code snippet provided below is able to display either a filled star or an empty star based on the current status of the object. It also triggers the appropriate function to favori ...

What is the validity of using Promise.reject().catch(() => 5) in Typescript?

Can you explain why the TS compiler is not flagging an error for this specific code snippet? Promise.reject().catch(() => 5) Upon inspecting the definition of the handler function within the catch, we come across the following code: interface Promise&l ...

What steps must be taken to resolve the error of setting headers after they have already been sent to the client?

Got a couple questions here. I've been using the express get method for a search query and it's fetching the requested tickets without any issues. However, I keep encountering errors even though the method itself is functioning properly. So, my f ...

New behavior in Vue 3: defineEmits is causing issues with defineProps data

Currently, I am working with Vue 3 and TS 4.4. In one of my components, I am using defineProps to define prop types. However, when I try to add defineEmits, VS Code starts indicating that my props variable is not recognized in the component template. Below ...

The shape-matching subset functionality in Typescript is experiencing issues

One of the key principles of TypeScript is that type checking focuses on the structure of values, a concept known as duck typing or structural typing. This means that only a subset of an object's fields needs to match for it to be considered compatibl ...

Tips for accessing a variable from a Global service in Ionic

I am currently working on developing an app using Ionic but experiencing some difficulties. I encountered an issue while trying to access a variable from a global service when it is imported to another page. Here is an example of the Global service (backen ...

What is the best way to determine the appropriate generic type for this situation?

Here is an example of some code: type secondaryObjectConstraint = { [key: string]: number } abstract class Base<TObject extends object, TSecondaryObject extends secondaryObjectConstraint> {} type secondaryObjectType = { myProp: number } c ...

What is the process for including external parameters in the webpack setup?

I'm attempting to create my project with webpack and here is my webpack configuration file. import * as path from 'path'; import * as webpack from 'webpack'; import { fileURLToPath } from 'url ...