← Back to Chapters

Use Proxy (Deprecated)

? Use Proxy (Deprecated)

? Quick Overview

The Use Proxy approach refers to routing requests through an intermediate proxy layer directly from client-side code. This pattern is now considered deprecated in most modern web architectures due to security, performance, and maintainability concerns.

? Key Concepts

  • Client-side proxy usage is discouraged
  • Proxies can expose sensitive credentials
  • Modern APIs rely on server-side gateways
  • CORS should be handled at the backend

? Syntax / Theory

Earlier implementations often relied on directly calling a proxy URL to bypass CORS or security restrictions. This approach is deprecated because it creates tight coupling between frontend and infrastructure.

? Code Example(s)

? View Code Example
// Deprecated example: client-side proxy usage
fetch("https://proxy.example.com/api/data")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));

? Live Output / Explanation

What Happens?

The browser sends requests through a third-party proxy. While it may work, it introduces security risks and is no longer recommended.

? Interactive Example

Simulate a request below to understand the security implications.

? View Source Code
// Modern approach: call your own backend instead of a proxy
fetch("/api/data")
.then(res => res.json())
.then(result => {
  console.log("Secure data:", result);
});
> System ready. Select a method above...

? Use Cases

  • Legacy systems (temporary support only)
  • Internal testing environments
  • Learning historical patterns

✅ Tips & Best Practices

  • Avoid exposing proxy URLs in frontend code
  • Move proxy logic to the backend
  • Use API gateways or middleware
  • Handle CORS properly on the server

? Try It Yourself

  • Replace a proxy call with a backend API route
  • Simulate CORS handling on the server
  • Compare network requests in DevTools