Skip to content

Commit

Permalink
RWK Connect Angular App to the Api + Expose Api over port 8080 + Use …
Browse files Browse the repository at this point in the history
…Cors configuration in Docker Environment
  • Loading branch information
Vivien FABING committed Nov 15, 2017
1 parent 987cc16 commit 5ebcf88
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion OMC.DockerApi/Startup.cs
Expand Up @@ -31,7 +31,7 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment() || env.EnvironmentName == "Docker")
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
Expand Down
5 changes: 5 additions & 0 deletions docker-angular/src/app/app.component.html
@@ -1,3 +1,8 @@
<h1> <h1>
{{title}} {{title}}
</h1> </h1>
<ul>
<li *ngFor="let value of values">
{{value}}
</li>
</ul>
22 changes: 22 additions & 0 deletions docker-angular/src/app/app.component.ts
@@ -1,4 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';


@Component({ @Component({
selector: 'app-root', selector: 'app-root',
Expand All @@ -7,4 +9,24 @@ import { Component } from '@angular/core';
}) })
export class AppComponent { export class AppComponent {
title = 'app works!'; title = 'app works!';

API = 'http://localhost:8080';

values: any[] = [];

constructor(private http: Http) { }

ngOnInit() {
this.getValues();
}

getValues() {
this.http.get(`${this.API}/api/values`)
.map(res => res.json())
.subscribe(values => {
console.log(values);
this.values = values;
});

}
} }
2 changes: 1 addition & 1 deletion docker-compose.override.yml
Expand Up @@ -5,7 +5,7 @@ services:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Docker - ASPNETCORE_ENVIRONMENT=Docker
ports: ports:
- "80" - "8080:80"
mssql: mssql:
environment: environment:
SA_PASSWORD: "YourStrong!Passw0rd" SA_PASSWORD: "YourStrong!Passw0rd"
Expand Down

0 comments on commit 5ebcf88

Please sign in to comment.