It can be a challenging situation when you have a different opinion from your team or the head developer or CTO and they don't accept your arguments because they have a different agenda for the project than what you had in mind when you joined the company. In this case, as a developer, there isn't much you can do.
If the point of contention is about a relatively minor technical difference which will work almost as well or which can be altered later if necessary, then it's no big deal. Sometimes if the solution takes the project in a totally unexpected direction which you aren't comfortable betting your career on, then you should let managers know why the solution is so important and if they don't see eye-to-eye, you can resign from the project and/or company. It rarely happens though. Maybe once or twice in a career.
If you communicate well, then usually you can reach consensus on any technical solution. But if the solution requires laying down a significant amount of ground work and it has flow-on implications on the business aspect or ethics of the project, then it makes sense to quit the company. In this case, as tempting as it is to just rip the band-aid off, I recommend to avoid this. Try to find a smooth way to transition out of the project and company if possible.
Sometimes it's tough because the company really wants you as a developer, but they don't want you to have any influence on management decisions. This is a difficult position because your future still depends on the commercial success of the project so it matters to you even if you have no control over it. The only thing you can do is let everyone know your point of view and if they don't agree and it's critical, then quitting may be the only option.