Home
Forums
New posts
Search forums
What's new
New posts
New resources
New profile posts
Latest activity
Resources
Latest reviews
Search resources
Members
Current visitors
New profile posts
Search profile posts
DMCA Policy
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
FEEL FREE TO SHARE TUTORIALS, YOUR SKILS & KNOWLEDGE ON CODING, SCRIPTS, THEMES, PLUGINS OR ANY RESOURCES YOU HAVE WITH THE COMMUNITY-
Click Here To Post Your Request,
JOIN COMPUTER REPAIR FORUM
Home
Forums
TUTORIALS
CODING TUTORIALS
Node.js
Simple Node.js Proxy
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="codeguru" data-source="post: 68" data-attributes="member: 2"><p>When I wanted to refresh my React.js skills, I quickly moved to create a dashboard of cryptocurrencies, their prices, and and other aspects of digital value. Getting rolling with React.js is a breeze — [ICODE]create-react-app {name}[/ICODE] and you’re off and running. Getting the API working isn’t quick, especially if they don’t accept cross-origin requests.</p><p></p><p>I set out to find the easiest possible Node.js proxy and I think I found it: [ICODE][URL='https://github.com/chimurai/http-proxy-middleware']http-proxy-middleware[/URL][/ICODE]; check out how easy it was to use:</p><p></p><p></p><p>// ... after `npm install express http-proxy-middleware`</p><p></p><p>const express = require('express');</p><p>const { createProxyMiddleware } = require('http-proxy-middleware');</p><p></p><p>const app = express();</p><p>app.use('/coins/markets', createProxyMiddleware({ </p><p> target: '<a href="https://api.coingecko.com/api/v3/coins/markets?vs_currency=USD&order=market_cap_desc&per_page=100&page=1&sparkline=false" target="_blank">https://api.coingecko.com/api/v3/coins/markets?vs_currency=USD&order=market_cap_desc&per_page=100&page=1&sparkline=false</a>',</p><p> headers: {</p><p> accept: "application/json",</p><p> method: "GET",</p><p> },</p><p> changeOrigin: true</p><p>}));</p><p>app.listen(3001);</p><p></p><p></p><p>After [ICODE]node server.js[/ICODE] is executed, I can hit [ICODE]http://localhost:3001/coins/markets[/ICODE] from my React app and receive quotes from CoinGecko’s API. Perfect!</p><p></p><p>I’m so grateful for projects like [ICODE][URL='https://github.com/chimurai/http-proxy-middleware']http-proxy-middleware[/URL][/ICODE] ; they allow us to easily move past development issues and help us move forward!</p><p></p><p>The post <a href="https://davidwalsh.name/simple-node-js-proxy" target="_blank">Simple Node.js Proxy</a> appeared first on <a href="https://davidwalsh.name" target="_blank">David Walsh Blog</a>.</p><p></p><p><a href="https://tkjs.us/dwb" target="_blank"><img src="https://davidwalsh.name/demo/tjs_block-1.svg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></p><p></p><p><a href="https://davidwalsh.name/simple-node-js-proxy" target="_blank">Continue reading...</a></p></blockquote><p></p>
[QUOTE="codeguru, post: 68, member: 2"] When I wanted to refresh my React.js skills, I quickly moved to create a dashboard of cryptocurrencies, their prices, and and other aspects of digital value. Getting rolling with React.js is a breeze — [ICODE]create-react-app {name}[/ICODE] and you’re off and running. Getting the API working isn’t quick, especially if they don’t accept cross-origin requests. I set out to find the easiest possible Node.js proxy and I think I found it: [ICODE][URL='https://github.com/chimurai/http-proxy-middleware']http-proxy-middleware[/URL][/ICODE]; check out how easy it was to use: // ... after `npm install express http-proxy-middleware` const express = require('express'); const { createProxyMiddleware } = require('http-proxy-middleware'); const app = express(); app.use('/coins/markets', createProxyMiddleware({ target: '[URL]https://api.coingecko.com/api/v3/coins/markets?vs_currency=USD&order=market_cap_desc&per_page=100&page=1&sparkline=false[/URL]', headers: { accept: "application/json", method: "GET", }, changeOrigin: true })); app.listen(3001); After [ICODE]node server.js[/ICODE] is executed, I can hit [ICODE]http://localhost:3001/coins/markets[/ICODE] from my React app and receive quotes from CoinGecko’s API. Perfect! I’m so grateful for projects like [ICODE][URL='https://github.com/chimurai/http-proxy-middleware']http-proxy-middleware[/URL][/ICODE] ; they allow us to easily move past development issues and help us move forward! The post [URL='https://davidwalsh.name/simple-node-js-proxy']Simple Node.js Proxy[/URL] appeared first on [URL='https://davidwalsh.name']David Walsh Blog[/URL]. [URL='https://tkjs.us/dwb'][IMG]https://davidwalsh.name/demo/tjs_block-1.svg[/IMG][/URL] [url="https://davidwalsh.name/simple-node-js-proxy"]Continue reading...[/url] [/QUOTE]
Insert quotes…
Verification
Post reply
Richest Freecoded User
Most Freecoin
freecoded
4,838 Freecoin
Davy200
590 Freecoin
J
Johnhendrick
575 Freecoin
S
Smith16
527 Freecoin
nathan69
426 Freecoin
Laureine
415 Freecoin
A
anajeen
370 Freecoin
C
codeguru
287 Freecoin
Tekera
267 Freecoin
A
Akubay
170 Freecoin
Home
Forums
TUTORIALS
CODING TUTORIALS
Node.js
Simple Node.js Proxy
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top