我使用docker-compose来对我的项目进行Docker化,我有 php,mysql,nodej.js ... 您可以在下面查看所有可能理解我的问题的源代码
代码docker-compose:
version: '2'
services:
db:
build: ./mysql
volumes:
- db_data:/var/lib/mysql
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=testDB
- MYSQL_USER=pass
- MYSQL_PASSWORD=devel
- MYSQL_ROOT_HOST=%
phpmyadmin:
build: ./phpmyadmin
links:
- db:db
ports:
- '8001:80'
php:
build: ./php
ports:
- '80:80'
restart: always
volumes:
- /home/samir2/www:/var/www/html
depends_on:
- db
node.js:
build: ./node.js
ports:
- '3000:3030'
volumes:
- /home/samir2/www:/var/www/html
volumes:
db_data:
当我尝试进行邮递时,我的Web服务与邮递员完美配合 将一些数据成功添加到已成功插入数据库的Web服务中。
但是当我尝试使用角度6中的请求
无法通过“ 405(不允许使用方法)”访问我的服务器
我的服务用户的代码
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {User} from "../model/user.model";
@Injectable()
export class UserService {
constructor(private http: HttpClient) { }
baseUrl: string = 'http://server/blog/public/api/register';
createUser(user: User) {
return this.http.post(this.baseUrl, user);
}
}
error message front angular.js
我的代码add-user.component.html
<div class="col-md-6">
<h2 class="text-center">Add User</h2>
<form [formGroup]="addForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" formControlName="email" placeholder="Email" name="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="firstName">First Name:</label>
<input formControlName="firstName" placeholder="First Name" name="firstName" class="form-control" id="firstName">
</div>
<div class="form-group">
<label for="lastName">Last Name:</label>
<input formControlName="lastName" placeholder="Last name" name="lastName" class="form-control" id="lastName">
</div>
<button class="btn btn-success">Update</button>
</form>
</div>
和add-user.component.ts
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {UserService} from "../service/user.service";
import {first} from "rxjs/operators";
import {Router} from "@angular/router";
@Component({
selector: 'app-add-user',
templateUrl: './add-user.component.html',
styleUrls: ['./add-user.component.css']
})
export class AddUserComponent implements OnInit {
constructor(private formBuilder: FormBuilder,private router: Router, private userService: UserService) { }
addForm: FormGroup;
ngOnInit() {
this.addForm = this.formBuilder.group({
id: [],
email: ['', Validators.required],
firstName: ['', Validators.required],
lastName: ['', Validators.required]
});
}
onSubmit() {
this.userService.createUser(this.addForm.value)
.subscribe( data => {
this.router.navigate(['list-user']);
});
}
}
有什么想法吗?