cookiecutter-sveltekit-fastapi icon indicating copy to clipboard operation
cookiecutter-sveltekit-fastapi copied to clipboard

Updating to latest SvelteKit

Open jarmitage opened this issue 2 years ago • 3 comments

Thanks for this template! I am attempting to bring it up to date with the latest SvelteKit but running into some issues...

You can see what I've tried so far here: https://github.com/jarmitage/cookiecutter-sveltekit-fastapi/commit/bc6f0a610976054a81a70e75b155cf486cca1d84

It seems like I am close, but the backend connection gets refused:

➜ npm run dev

> [email protected] dev
> run-p frontend:dev backend:dev


> [email protected] frontend:dev
> svelte-kit dev


> [email protected] backend:dev
> uvicorn app.main:app --reload

INFO:     Will watch for changes in these directories: ['/Users/jarm/Documents/git/pro/iil/py/iil-python-tools/examples/sveltekit/iipyper_basic_gui']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

  SvelteKit v1.0.0-next.308

  local:   http://localhost:3000
  network: not exposed
  network: not exposed
  network: not exposed

  Use --host to expose server to other devices on this network


INFO:     Started reloader process [19696] using watchgod
INFO:     Started server process [19698]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
11:32:43 [vite] http proxy error:
Error: connect ECONNREFUSED ::1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

Any ideas?

jarmitage avatar Apr 07 '22 11:04 jarmitage

Sorry for taking so long. I just updated the dependencies versions on c5a44fd3e44a7e11fcbb3a5b976dfc5c7bfd4bff

Since the frontend app is based on npm init svelte, I tried to sync all the changes to it. So, I probably updated more things than were necessary.

PS: I haven't had the chance to try on heroku yet as I don't have time to update my project that is hosted there and I'm using this cookie-cutter right now only for a local server.

Something that may break there is that I removed the PORT environment variable from https://github.com/JoaoFelipe/cookiecutter-sveltekit-fastapi/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/svelte.config.js#L6. This change was necessary because SvelteKit changed the env variable and I couldn't dedicate a time to figure out if it was just renamed to envPrefix or if the semantics changed. By inspecting the node-adapter, it seems that it uses the PORT environment variable by default now, so it looked unnecessary to keep the previous config.

Please, if it doesn't work on heroku, let me know.

JoaoFelipe avatar Jun 17 '22 06:06 JoaoFelipe

Thanks for the updates - I am able to run the app.

Trying this locally though, I am still receiving the same error:

10:24:22 [vite] http proxy error:
Error: connect ECONNREFUSED ::1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

Do you think this is related to the PORT env variable as you mentioned?

jarmitage avatar Jun 22 '22 10:06 jarmitage

Late to the party but anyone trying to use this template, change localhost to 127.0.0.1 in svelte.config.js (Per https://github.com/vitejs/vite/discussions/7620)

junghanw avatar Oct 11 '22 06:10 junghanw