Forum Discussion

stevensullivan's avatar
8 years ago

How to identify requested url of a "Node Not Found" error

If a node does not exist, the coreNode context object seems to revert to a default. Is there any way in freemarker to check what node the user was attempting to reach?

 

I would ideally be performing this check in the common.init so that I can run some logic to either show the NNF error or initiate a redirect, depending on what node was requested. 

  • DougS's avatar
    DougS
    Khoros Oracle

    I believe the coreNode object gets created based on the "node" that is installed for the page you are viewing. I think in the case of a NNF error, you the request has already been  sent (either redirected or forwarded, don't remember which) to the "404 page" which has the community set as the coreNode.

     

    I don't think we currently have a way in common.init to tell what node was trying to be hit when the 404 page was served.

     

    If you control the initial redirect to the page that is getting the NNF error, you could make a REST API call as that user to look up the node (board or category) for the page you are about to redirect to and redirect elsewhere if that returns as "not found". 

     

     Another thing you could try is adding some javascript (client-side) logic that checks the http status code of the response -- it will be 404 in this case and then you could possibly parse the board or category id out of the URL. In addition to that possibly looking strange to the end-user, it seems like that might be a bit error-prone and could break if URL schemes change or a new one is added.