title: Is there a way to serve files to browser and data to rest requests using the same endpoint?
body: <p>I've followed this <a href="https://www.youtube.com/watch?v=VsUzmlZfYNg" rel="nofollow noreferrer">7 hour tutorial</a> on creating a blog almost to. There is one step that I skipped, because I did not want to use the separate client/server hosting that the tutorial suggests. Instead, I have a single heroku server that serves the client out of the public server:</p>
  <pre><code>const app = express();
  app.use(express.static('public'))
  app.use('/posts', postRoutes);
  app.use('/user', userRoutes)
  </code></pre>
  <p>You can see that the app also serves some rest requests to the <code>/posts</code> and <code>/user</code> paths. However, the tutorial also led me to add these paths into the url client-side.</p>
  <p>For example, you can access my app at (<a href="https://blog-tutorial-888.herokuapp.com" rel="nofollow noreferrer">https://blog-tutorial-888.herokuapp.com</a>), but you will be immediately &quot;redirected&quot; to (<a href="https://blog-tutorial-888.herokuapp.com/posts" rel="nofollow noreferrer">https://blog-tutorial-888.herokuapp.com/posts</a>).</p>
  <p>I say &quot;redirected&quot; because on the client side, it appears that you are at that site, and the purpose is so that you can do things like navigate to the next page, which will be at (<a href="https://blog-tutorial-888.herokuapp.com/posts?page=2" rel="nofollow noreferrer">https://blog-tutorial-888.herokuapp.com/posts?page=2</a>).</p>
  <p>But if you were to actually go to these links, or refresh the page, you will be hit with the result of the rest request, which is a giant block of text (and this is obviously because I have <code>app.use('/posts', postRoutes)</code>).</p>
  <p>Is there a way to get around this somehow? Somehow serve both the html and the rest request at this endpoint?</p>