angular / angular.io

Website for the Angular project (see github.com/angular/angular for the project repo)
https://angular.io
MIT License
1.03k stars 880 forks source link

The requested url was not found on this server -Why ? #3560

Closed usman10scorpio closed 7 years ago

usman10scorpio commented 7 years ago

I have an angular2 app, and its hitting an api which is placed in my wamp/www . When i try to hit the api i get this error.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
     <html><head>
     <title>404 Not Found</title>
     </head><body>
     <h1>Not Found</h1>
     <p>The requested URL /usmanproject/api/web/v1/users was not found on this server.</p>
     <hr>
     <address>Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80</address>
     </body></html>

My angular app is running on localhost:4200and the angular project folder is also placed in wamp/www but it is not working.

This is my angular code


     private heroesUrl = 'http://localhost/usmanproject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0';  // URL to web api

        private headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });

        create(): Promise<any> {
            return this.http
                .get(this.heroesUrl)
                .toPromise()
                .then(res => res.json().data)
                .catch(this.handleError);
        }

The backend is made in yii2. I have tested the api http://localhost/usmanproject/api/web/v1/users?access-token=n-EJtZiejtz5RSVWe-U14G4kCnPWMKf0 in postman, its working perfectly fine over there.

malvia commented 7 years ago

thanks