netlify site name. geralds-test-app.netlify.app
I have a brand new angular project with netlify that has a single endpoint that calls a test function. The function/endpoint is being called however the event
object is always empty and I can not pass query params or a request body to it. I’ve spent 2 nights trying to resolve the issue to no avail.
This is my output when I start up with netlify dev
. Notice event
is empty and there are no query params.
Request from ::1: GET /.netlify/functions/test-params?id=3
Received event: {}
Event object: Request {
method: 'GET',
url: 'http://localhost:3000/.netlify/functions/test-params?id=3',
headers: Headers {
'x-forwarded-for': '::1',
'x-nf-blobs-info': 'eyJ1cmwiOiJodHRwOi8vbG9jYWxob3N0OjU5NzEwIiwidXJsX3VuY2FjaGVkIjoiaHR0cDovL2xvY2FsaG9zdDo1OTcxMCIsInRva2VuIjoiMTQ5MWZiMDEtOGJmNi00MzZkLWI2MjctOGY3YmI2NWUwY2QzIn0=',
'x-nf-account-info': 'eyJpZCI6IjY4NzViYzU1NTFiYWZlMjIzNjFlMTdhNiJ9',
'x-nf-site-info': 'eyJpZCI6IjlkMWMyMzBmLWVkNmMtNGNkNC1hNGIzLTEzZTUwNWExNjM2MSIsIm5hbWUiOiJnZXJhbGRzLXRlc3QtYXBwIiwidXJsIjoiaHR0cDovL2xvY2FsaG9zdDozMDAwIn0=',
'x-nf-deploy-context': 'dev',
'x-nf-deploy-id': '0',
'x-nf-geo': 'eyJjaXR5IjoiU291dGggSm9yZGFuIiwiY291bnRyeSI6eyJjb2RlIjoiVVMiLCJuYW1lIjoiVW5pdGVkIFN0YXRlcyJ9LCJzdWJkaXZpc2lvbiI6eyJjb2RlIjoiVVQiLCJuYW1lIjoiVXRhaCJ9LCJ0aW1lem9uZSI6IkFtZXJpY2EvRGVudmVyIiwibGF0aXR1ZGUiOjQwLjU1MjYsImxvbmdpdHVkZSI6LTExMS45NDUzLCJwb3N0YWxDb2RlIjoiODQwOTUifQ==',
'accept-encoding': 'gzip, deflate',
'user-agent': 'node',
'sec-fetch-mode': 'cors',
'accept-language': '*',
accept: 'application/json, text/plain, */*',
connection: 'close',
host: 'localhost:3000',
'x-nf-request-id': '01K0X3MVFMHEQF22T86Y0RNTB6',
'client-ip': '::1',
'x-nf-client-connection-ip': '::1',
'x-nf-account-id': '6875bc5551bafe22361e17a6',
'x-nf-site-id': '9d1c230f-ed6c-4cd4-a4b3-13e505a16361'
},
destination: '',
referrer: 'about:client',
referrerPolicy: '',
mode: 'cors',
credentials: 'same-origin',
cache: 'default',
redirect: 'follow',
integrity: '',
keepalive: false,
isReloadNavigation: false,
isHistoryNavigation: false,
signal: AbortSignal { aborted: false }
}
HTTP Method: undefined
Query parameters: undefined
Response with status 200 in 279 ms.
Here are my project specs from my package.json:
"dependencies": {
"@angular/common": "^20.0.0",
"@angular/compiler": "^20.0.0",
"@angular/core": "^20.0.0",
"@angular/forms": "^20.0.0",
"@angular/platform-browser": "^20.0.0",
"@angular/platform-server": "^20.0.0",
"@angular/router": "^20.0.0",
"@angular/ssr": "^20.0.5",
"@netlify/angular-runtime": "^2.4.0",
"express": "^5.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/build": "^20.0.5",
"@angular/cli": "^20.0.5",
"@angular/compiler-cli": "^20.0.0",
"@types/express": "^5.0.1",
"@types/jasmine": "~5.1.0",
"@types/node": "^20.17.19",
"jasmine-core": "~5.7.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.8.2"
}
Node version 20.19.4
npm version 11.4.2
Here is my app.ts
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.html',
styleUrl: './app.scss'
})
export class App implements OnInit {
protected title = 'test-app';
constructor(private http: HttpClient) { }
ngOnInit(): void {
this.http.get(`/.netlify/functions/test-params?id=3`).subscribe();
}
}
Here is my test function from my functions
folder
export default async (event, context) => {
console.log('Received event:', JSON.stringify(event, null, 2));
console.log("Event object:", event);
console.log("HTTP Method:", event.httpMethod);
console.log("Query parameters:", event.queryStringParameters);
return new Response(JSON.stringify({
message: 'Invoke test successful',
qs: event.queryStringParameters || 'no query params'
}), {
headers: { 'Content-Type': 'application/json' },
status: 200
});
};
Here is my .toml
[build]
command = "npm run build"
functions = "netlify/functions"
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[dev]
functions = "functions"
command = "ng serve"
port = 3000
publish = "dist"
What am I doing wrong? Why can’t I pass query params to my netlify functions/endpoints?
I have also tried with netlify-cli v21 and node 20.19.4.
I have tried using curl e.g (curl "http://localhost:8888/.netlify/functions/yourFunctionName?param1=value1¶m2=value2"
)
I have tried netlify functions:invoke
I have tried uninstalling and reinstalling netlify
I have tried creating a complety new angular/netlify app from scratch