Should you publish your book online for feedback?

This is a question I’ve had in my mind and have been a bit curious about. Let’s say I finish writing a novel but before publishing it, I want to get feedback on it. Should I publish it online somewhere? I was thinking having it online for free would probably discourage publishers from publishing your book.

Is it fine to publish it online? If yes, are there specific sites that I should/should not use for this? If no, what would be a good alternative way to get feedback and opinions from people?