mean-expert-official / loopback-component-realtime

The LoopBack Component that turns this great framework into a powerful real-time platform
MIT License
30 stars 17 forks source link

Socket.IO url not updated using config update #39

Open appunnicer13 opened 7 years ago

appunnicer13 commented 7 years ago
export class AppComponent {
  title = 'Note App';

  private note : Note = new Note();
  private reference : FireLoopRef<Note>;

  constructor(private realTime: RealTime) {
    LoopBackConfig.setBaseURL(BASE_URL);
    LoopBackConfig.setApiVersion(API_VERSION);
    this.realTime
      .onReady()
      .subscribe(() =>
        this.reference = this.realTime.FireLoop.ref<Note>(Note)
      );
  }
}

This is not working for Socket URL , socket is still using ws://0.0.0.0:3000 by default. Please update on this soon.

using "@mean-expert/loopback-component-realtime": "^1.0.0-rc.9.4",

export const BASE_URL = '//localhost:3000'; export const API_VERSION = 'api';

jonathan-casarrubias commented 7 years ago

@appunnicer13 thanks for reaching out, for web socket configuration it is better to set the baseUrl within the main.ts file,

Try moving the configs to your main.ts file instead,

something like

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
import {LoopBackConfig} from './app/shared/sdk';

LoopBackConfig.setBaseURL(BASE_URL);
LoopBackConfig.setApiVersion(API_VERSION);

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);