-1

I am using this regex in my router

/^\/(?!api|mailAction(\/|\?))(.*)$/

as the router allows only api/ or api? or mailAction/ or mailAction?

Now the router is set as following -

app.get(/^\/(?!api|mailAction(\/|\?))(.*)$/, (req, res) => {
            console.log('not matched')
            if (req.isMobile) {
                return res.sendFile(path.join(FE.APP_PATH, "dist", "mob", this.clientName, "index.html"));
            } else {
                return res.sendFile(path.join(FE.APP_PATH, "dist", "web", this.clientName, "index.html"));
            }
        });

Still when the URL is http://fe.localhost:4000/mailAction?t=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXfVCJ9.eyJ0b2tlbklkIjo2MywiaWF0IjoxNTg0MDE4NjE2LCJleHAiOjE1ODQwNTQ2MTZ9.mCKwrMN2ppLlEMSp4U1_AwmNLDOjplOmnYTaFADf6FQ&a=ACT00000205 it serves the index.html file as written in middleware. I am not able to understand why. Please help.

Thanks in advance.

1 Answers1

-1

Have you tried like this (without negative lookahead)?

^\/(api|mailAction)(.*)$

radulle
  • 1,437
  • 13
  • 19