netlify / create-react-app-lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Neither of the buttons work

wildlySpeculating opened this issue · 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

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

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,
    })
  );
};

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