Authentication
1. Delete FakeLoginService
The FakeLoginService is only for demonstrating the effect before and after login and should not exist in a real-world project.
Remove the src\app\fake-login.service.ts file.
Next, make some modifications to the application configuration.
// app.config.ts
-import { FakeLoginService } from './fake-login.service';
...
export const appConfig: ApplicationConfig = {
providers: [
...
- // ==================================================
- // 👇 ❌ Remove it in the realworld application
- //
- { provide: LoginService, useClass: FakeLoginService },
+ { provide: LoginService, useClass: LoginService },
...
]
}2. Using a Local Proxy
We recommend accessing the backend API endpoints through a proxy in a development environment, while using tools like nginx for deployment in production environments.
3. Login Service
After that, the network request address for the login service needs to be modified.
Based on the actual situation, you can modify the return type of the request, such as encapsulating the response data with additional information.
SP. Nginx Deployment
Here is a simplified introduction to the configuration method for nginx, which mainly involves rewriting the path for the API endpoints, consistent with typical reverse proxy setups.
Last updated
Was this helpful?