No Webview for React + Vite + Typescript project?

Question:
Hello, I have a React project I made on my local machine and pushed to a GitHub repo. I created a new project in Replit “from existing GitHub repo.” In the .replit file, I set run = "npm run build" . The build runs successfully and compiles to the dist folder, however no web preview appears. What am I missing?

Repl link:
https://replit.com/@wdlord/APOD-front-end#.replit

no code snippet cuz I have no idea where the problem is, but probably .replit or some other config file.

Hey @wdlord, welcome!

Have you tried looking for the Webview under Tools in the sidebar?

If you can’t find it there, I was able to open the website at https://apod-front-end.wdlord.repl.co/. Please let me know if this works for you. If it does, I’d recommend having a split screen of your Repl workspace and the site.

Hello thanks for the reply, I literally just figured out my problem so that’s probably why it’s working now. My vite config file did not specify a server:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    host: '0.0.0.0',
  }
})

Adding the server: { host: '0.0.0.0',} fixed my problem!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.