create-react-app-lambda icon indicating copy to clipboard operation
create-react-app-lambda copied to clipboard

Neither of the buttons work

Open wildlySpeculating opened this issue 5 years ago • 3 comments

Clicking either button doesn't send a response. I think the issue is that on the front end it can't find the lambda functions at '/.netlify/functions/' but I can't figure out why

wildlySpeculating avatar Apr 14 '20 03:04 wildlySpeculating

soryr i dont maintain this anymore - try checking in with netlify community/support

swyxio avatar Apr 19 '20 11:04 swyxio

This repo is pretty much a mess. Try adding the following to src/proxySetup.js so that CRA will proxy requests to /.netlify/functions/ to http://localhost:9000/.netlify/functions/ (the Netlify functions server).

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function (app) {
  app.use(
    '/.netlify/functions/',
    createProxyMiddleware({
      target: 'http://localhost:9000/',
      changeOrigin: true,
    })
  );
};

donavon avatar May 08 '20 20:05 donavon

Hi for this to work now you need to add file src/proxySetup.js with the following syntax, then run-> ntl dev

const proxy = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    proxy('/.netlify/functions/', {
      target: 'http://localhost:8888/'
    })
  );
};

here is my boilerplate.. it even has node functionality as-well

https://github.com/Kirbyasdf/netlify-react-lambda-NODE-boilerplate

Kirbyasdf avatar Jun 29 '20 04:06 Kirbyasdf