strukturart / greg

Calendar for KaiOS
MIT License
26 stars 7 forks source link

Unable to proxy because all urls seem to be caught by the app #37

Closed zeekoe closed 9 months ago

zeekoe commented 9 months ago

Hi strukturart! I'm looking into a way to debug the app locally and got the idea of proxying requests. It looks like parcel supports that. My suggested readme entry was supposed to be this:

If you want to connect to a remote Nextcloud server, create a .proxyrc.json file with the following contents:

{
  "/api": {
    "target": "https://nextcloud-server-url:port/",
    "pathRewrite": {
      "^/api": ""
    }
  }
}

Using http://localhost:1234/api/remote.php/dav as CardDAV URL should then do the trick.

...however, it seems that all requests to http://localhost:1234/put-anything-here get redirected to greg. Is there an easy way to stop this, perhaps for a specific path like /api? That would make local development much more easy.

strukturart commented 9 months ago

I'm sorry I can't help because I've never tried it and I'm not very familiar with parcel. why don't you use a real nextcloud account for debugging?

zeekoe commented 9 months ago

Hmm, I hoped that it was something configured in the application independent of how one runs it, that all paths go to the main app. I do use a real nextcloud account, but when I run the app in parcel, my browser blocks the queries because they go to a different server. I tried an extension to allow CORS requests, but it also didn't work. If there is another way, I would be very happy to try it!

strukturart commented 9 months ago

Do you have a KaiOS device in dev mode to test?

zeekoe commented 9 months ago

Thanks again for your help! I do have a KaiOS device and can put it in dev mode. However, the debug cycle is much shorter on a laptop (parcel can live-update at any source file change, I don't think that's possible with the real device?), so that has my strong preference for developing. ...and I got it to work! Took me a while, but finally using snippets from https://www.williamjbowman.com/blog/2021/05/13/enabling-cors-for-nginx-webdav-and-caldav-reverse-proxy/ in my Nextcloud nginx configuration and adding the REPORT request type now makes all run smoothly. I'm happy to share in more detail in case it's of help to anyone.