Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thesimons's avatar

API vs standard routes for internal ajax urls

Hello,

I have a user signup form and I'm validating it using ajax. Username must be unique so I use ajax to check for it.

Ajax needs an URL where to send the post request. This URL is for internal use only. No external application / domains / sites will use it.

I was wondering what's the best approach between using a normal route or an api route according to Laravel best practices.

Thanks, Simon

0 likes
1 reply
Snapey's avatar

I always use web routes for ajax requests.

Save API routes for communicating with third parties who shouldnt / cant use sessions

1 like

Please or to participate in this conversation.