Hello,
I use netlify functions and everything is working fine in dev mode (localhost) , however when I switch to production mode, on every request I get the following error: “You need to enable JavaScript to run this app.” Does anybody knows what might be the problem?
https://remarkable-naiad-45d682.netlify.app
Hiya, sorry you are having trouble with your build.
This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.
We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!
If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, a full copy of your most recent deploy log, your package.json
, etc. Thanks!
Hello Hillary,
Thanks for your message!
The first problem was because the redirects weren’t working. I now deleted the _redirects file and exported it to netlify.toml and the redirects do seem to work.
However I still can’t get the functions to work. It says:
“Runtime.HandlerNotFound - activity.handler is undefined or not exported” - https://remarkable-naiad-45d682.netlify.app/api/activity
In localhost everything is running fine!
Any ideas?
Okay, so I am sure it has to do something with including files in subdirectories.
My code is as follows:
const activity = require("./activity");
const fnHeaders = require("./_shared/headers");
exports.handler = function (event, context) {
const claims = context.clientContext && context.clientContext.user;
const query = Object.keys(event.queryStringParameters)[0];
if (claims && event.httpMethod == "GET") {
switch (query) {
case "getActivities":
return activity.getActivities(event, context);
}
}
........
In the functions/activity/index.js folder I require the getActivities file, which returns a response. This works in localhost, but not in production. Is there a way I can get this to work in production? This helps me to get a clear folder structure.
Hard to say by looking at that piece of code. Is it possible to share a reproduction, possibly minimal?