Function to create URL relative to a configured base URL I have written this function to create a URL:

function createUrl(urlPath) {
    const endpoint = url.parse(env.config.get('myEndpoint'));
    endpoint.pathname = path.posix.join(endpoint.pathname, urlPath);
    return endpoint;
}


const basically creates a mutable object whose properties can still be modified. 
Here, I need to declare some Object which will only be modified once. Am I correct in declaring endpoint as const?
Yes, it's correct to use const here. That would be considered idiomatic Javascript. If you're using const when you shouldn't, you'll notice as it will produce a TypeError.

People coming from other languages might disagree as they think that const means that the variable is constant/immutable (which is not the case, it's just not re-assignable). But that is really a critique of the naming of the keyword, not your usage of the keyword (which is correct).