Support Forums

Google Storage Get Signed URL is working locally but not in netlify functions

I tried the function locally it works. The moment I push it to netlify I get an error from the getSignedUrl function.

This is my code to get a signed url to upload securely to google cloud storage.

        const [url, err] = await storage.
                    action: 'write',
                    version: 'v4',
                    expires: Date.now() + 15 * 60 * 1000, //15 minutes

        console.log('url:' + url);

In the functions log I get the following error:

5:58:57 AM: 48670ca5 INFO   TypeError: i.format is not a function
    at t.URLSigner.getSignedUrlV4 (/var/task/lambda/server.js:1690:10492)
    at t.URLSigner.getSignedUrl (/var/task/lambda/server.js:1690:9160)
    at j.getSignedUrl (/var/task/lambda/server.js:1219:73279)
    at /var/task/lambda/server.js:458:741
    at new Promise (<anonymous>)
    at j.r (/var/task/lambda/server.js:458:622)
    at t.getWriteSignedUrl (/var/task/lambda/server.js:823:2598)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async t.getFileUploadUrl (/var/task/lambda/server.js:2981:105805)
5:58:57 AM: 48670ca5 INFO   Error: No url returned
    at t.getFileUploadUrl (/var/task/lambda/server.js:2981:105830)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
5:58:57 AM: 48670ca5 Duration: 35.51 ms	Memory Usage: 98 MB	

I am wondering if this has to do with node version. Locally I am using v15.8. I tried changing the NODE_VERSION environment variable but I still get the error. Any help is much appreciated.

NODE_VERSION variable that you set it used to build the websites and not as AWS Runtime. To set that, you’ve to choose one o these:

(Lambda runtimes - AWS Lambda)

The name of the variable is: AWS_LAMBDA_JS_RUNTIME

Coming back to the original question, which the code you posted above, it’s not possible to guess the error. It can help if you post your code or repo to test.