0

I try to create simple PWA in PhpStorm. I have 2 files:

  • home.html
  • manifest.json

File home.html contains link to manifest.json:

<link rel="manifest" href="/manifest.json">

When I open home.html using PhpStorm built-in web server I have error 404 for manifest.json in Chrome console:

Failed to load resource: the server responded with a status of 404 (Not Found)

I can open home.html in browser from context menu: enter image description here

but I haven't this option for manifest.json: enter image description here

Can I configure built-in web server in PhpStorm to work with JSON or this is not possible?

Alex Gusev
  • 1,526
  • 3
  • 16
  • 35

1 Answers1

2

The problem is caused by your URL (href="/manifest.json"): leading slashes tell the browser to resolve URLs from the web server root. Internal web server returns 404 when using 'absolute' URLs as it serves files from localhost:port/project_name and not from localhost:port. If you like your URLs to be resolved when hosting your app on the built-in web server, use URLs relative to current file (href="path/relative/to/home.html/manifest.json")

lena
  • 90,154
  • 11
  • 145
  • 150