I made a small change in my netlify site (built on gatsby) by adding getServerData function to inject server side props. I am calling a netlify function here. For some reason, I get a 500 Internal server error. I am unable to check anything in the logs. Here is my function
Here’s the change I made. I am guessing it has access to process.env environment variables? I’ve set the corresponding env value to the deploy preview env variable.
With that being said, I don’t really understand why you’re doing it this way. Why not implement the functionality from the Netlify Function in your server-side code? I don’t understand the reasoning here for making 2 function invocations for a single request.
Is there any other way I can inject country information? I read in the redirect docs about netlify being able to redirect based on geoip.
Is it possible to somewhat do this? The user goes to / and then netlify automatically adds a query param with country code? or redirect to path based on the country of origin? /?country=nl or /nl. It could be any country.
And I am calling this edge function from ssr-engine (Please tell me if there’s some other way to use edge function in the place of ssr-engine so that I can get the geo location)
Although the edge function works, I am facing the same 500 error which I have no clue about. Can you please support me and tell me why this is happening?
Oct 8, 11:02:00 PM: INIT_START Runtime Version: nodejs:18.v13 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:0229ff5ced939264450549058d8f267110e92677c27063e6dcd781a280f2462b
Oct 8, 11:02:00 PM: 2023-10-08T21:02:00.999Z undefined INFO Preparing Gatsby filesystem {
from: '/var/task/.cache',
to: '/tmp/gatsby/.cache',
rewrites: [
[ '/var/task/.cache/caches', '/tmp/gatsby/.cache/caches' ],
[
'/var/task/.cache/caches-lmdb',
'/tmp/gatsby/.cache/caches-lmdb'
],
[ '/var/task/.cache/data', '/tmp/gatsby/.cache/data' ]
]
}
Oct 8, 11:02:01 PM: 2023-10-08T21:02:01.002Z undefined INFO Start copying data
Oct 8, 11:02:01 PM: 2023-10-08T21:02:01.009Z undefined INFO End copying data
Oct 8, 11:02:02 PM: /bin/sh: lscpu: command not found
Oct 8, 11:02:02 PM: Downloaded datastore from CDN
Oct 8, 11:02:04 PM: error Engine failed to handle request Error: ENOENT: no such file or directory, stat '/opt/build/repo/content/retreats/nvckenya_hero_image2.jpg'
Oct 8, 11:02:04 PM: at Object.statSync (node:fs:1690:3)
Oct 8, 11:02:04 PM: at Object.statSync (/var/task/node_modules/graceful-fs/polyfills.js:318:34)
Oct 8, 11:02:04 PM: at Object.lfs.<computed> (/var/task/node_modules/linkfs/lib/index.js:144:25)
Oct 8, 11:02:04 PM: at Object.statSync (/var/task/.cache/query-engine/index.js:6772:34)
Oct 8, 11:02:04 PM: at opts.dereference.fs.lstatSync.bigint (/var/task/.cache/query-engine/index.js:7408:20)
Oct 8, 11:02:04 PM: at getStatsSync (/var/task/.cache/query-engine/index.js:7410:19)
Oct 8, 11:02:04 PM: at Object.checkPathsSync (/var/task/.cache/query-engine/index.js:7452:33)
Oct 8, 11:02:04 PM: at Object.copySync (/var/task/.cache/query-engine/index.js:7573:38)
Oct 8, 11:02:04 PM: at resolve (/var/task/.cache/query-engine/index.js:328363:14)
Oct 8, 11:02:04 PM: at wrappedTracingResolver (/var/task/.cache/query-engine/index.js:133158:20)
Oct 8, 11:02:04 PM: at executeField (/var/task/.cache/query-engine/index.js:105913:20)
Oct 8, 11:02:04 PM: at executeFields (/var/task/.cache/query-engine/index.js:105835:22)
Oct 8, 11:02:04 PM: at completeObjectValue (/var/task/.cache/query-engine/index.js:106335:10)
Oct 8, 11:02:04 PM: at completeValue (/var/task/.cache/query-engine/index.js:106065:12)
Oct 8, 11:02:04 PM: at /var/task/.cache/query-engine/index.js:105918:9
Oct 8, 11:02:04 PM: at processTicksAndRejections (node:internal/process/task_queues:95:5)
Oct 8, 11:02:04 PM: 34ed0007 Duration: 1499.85 ms Memory Usage: 337 MB Init Duration: 1973.89 ms