swifter icon indicating copy to clipboard operation
swifter copied to clipboard

404 Not Found

Open ajitam opened this issue 2 years ago • 0 comments

Hello, I have a task of "reviving" someone else iOS app which uses your (Swifter) library. I've encountered quite weird problem:

Here is the setup:

  • application has files in some location (lets say /serve on the phone (there is a folder called webapp and inside is index.html and folder res with some css files)
  • application creates server
server["/:path"] = shareFilesFromDirectory(servePath)
# servePath = "...serve/"
  • application presents webview pointing request to http://localhost:8080/webapp/index.html

Main problem is that I get Status code: 404

Here are my findings:

  • files are there - I'm listing whole folder tree and printing content of index.html
  • swifter (and webview) works I replace
server["/:path"] = shareFilesFromDirectory(servePath)

with

server["/webapp/index.html"] = { .ok(.htmlBody("You asked for \($0)"))  }

and I get You ask for... in webview

  • if I add servePath /webapp and the end and remove it from webview request (making it http://localhost:8080/index.html) - webpage loads with out no style. I then went in with inspector and saw that all other files get 404 (so for example http://localhost:8080/src/main.css)]

Is there something with directories that is blocking (permissions or sth)?

Thx for the help

ajitam avatar Aug 30 '22 20:08 ajitam