Skip to content

Commit

Permalink
Set up proxy for business search
Browse files Browse the repository at this point in the history
  • Loading branch information
oliv-yu committed May 20, 2024
1 parent ed56d7c commit d62825e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/components/BusinessCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function BusinessCard({ location, onChangeLocation }) {
axios
.request({
method: 'GET',
// for local development `lcp --proxyUrl https://api.yelp.com/` to avoid CORS issue
// url: 'http://localhost:8010/proxy/v3/businesses/search',
url: 'https://api.yelp.com/v3/businesses/search',
url: '/v3/businesses/search',
params: {
sort_by: 'best_match',
limit: '10',
Expand Down
11 changes: 11 additions & 0 deletions src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const createProxyMiddleware = require('http-proxy-middleware')

module.exports = function (app) {
app.use(
'/v3/businesses/search',
createProxyMiddleware({
target: 'https://api.yelp.com',
changeOrigin: true,
})
)
}

0 comments on commit d62825e

Please sign in to comment.