I'm trying to setup a NodeJS REST API using Google Cloud Endpoints and Google App Engine. I've cloned the offical sample project from GitHub and set up Google Cloud Endpoints using the Quickstart. Out of the box, it works fine,but I tried adding another API endpoint for a GET request at /
, but the response I get after I deploy and make the request is as follows:
{
"code": 5,
"message": "Method does not exist.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "service_control"
}
]
}
The APIs which came pre-configured works fine, but only new ones which I add aren't working.
I've configured the new endpoint properly in my NodeJS app (it works fine locally). The corresponding code I've added is:
app.get('/', function (req, res) {
res.status(200).json({ message: 'Hello, world!' });
});
I've added the following to my openapi.yaml
file:
paths:
"/":
get:
description: "Returns the message \"Hello, World\""
operationId: "root"
produces:
- "application/json"
responses:
200:
description: "Hello"
schema:
$ref: "#/definitions/helloMessage"
definitions:
helloMessage:
properties:
message:
type: "string"
After running gcloud service-management deploy openapi.yaml
from a terminal to deploy and configure Google Cloud Endpoints, I got the service name and the service configuration ID, which I've replaced in app.yaml
, in the format specified by the QuickStart
endpoints_api_service:
name: echo-api.endpoints.[YOUR-PROJECT-ID].cloud.goog
config_id: YOUR-CONFIG-ID
(That's the format, I've replaced YOUR-PROJECT-ID
and YOUR-CONFIG-ID
with the right ones)
I deployed the app to Google App Engine using gcloud app deploy
. I can see the app running properly, via the Google App Engine console.
Yet, the GET method on /
is not being identified as a valid endpoint and I get the response as stated above.
Am I missing something? I searched a lot about this problem, but didn't come across anything useful/similar!
P.S: By added, I mean, it is the code which I've added to the corresponding GitHub cloned files
EDIT:
I changed the API endpoint from /
to /hello
and it works fine!! Unable to understand why the same functionality on /
is not working on Google Cloud Endpoints (works locally though!)
Google Cloud Endpoints does not currently support the root path at "/". This is something that is being looked into.