ocram
ocram

Reputation: 1444

Why do I need a server with create-react-app

I recently created a website with create-react-app. Since this is not a web app, why do I need a server to see it? I tried to open the index file in build folder but it doesn't work unless I'm serving it from a server.

Upvotes: 5

Views: 2750

Answers (1)

Martin
Martin

Reputation: 7149

You can set the homepage root url in the package.json file e.g.

{
   ...,
   "homepage":"file:///<path to build directory"
}

npm run build

This will now find the static content in the build directory from the file system without a server.

Upvotes: 5

Related Questions