snapp icon indicating copy to clipboard operation
snapp copied to clipboard

ERR_INVALID_URL

Open matsicking opened this issue 7 months ago • 10 comments

I get this Error:

snapp_1  | 678 | var ssr = function(request) {
snapp_1  | 679 |   if (origin) {
snapp_1  | 680 |     const requestOrigin = get_origin(request.headers);
snapp_1  | 681 |     if (origin !== requestOrigin) {
snapp_1  | 682 |       request = new Request(origin + url, {
snapp_1  |                       ^
snapp_1  | TypeError: Failed to construct 'Request': Invalid URL "sub.domain.tld/"
snapp_1  |  code: "ERR_INVALID_URL"
snapp_1  |
snapp_1  |       at ssr (/app/build/handler.js:682:17)

And i have absolutely no clue how to fix it, can anyone here help? (I replaced the domain in the code) I'm using docker, with this compose file:

services:
  snapp:
    image: uraniadev/snapp:latest
    ports:
       - 5999:3000
    environment:
      ORIGIN: sub.domain.tld
      PUBLIC_URL: https://sub.domain.tld
      DATABASE_PROVIDER: sqlite
      DATABASE_URL: file:./db.sqlite
      TOKEN_SECRET: myextremlytopsecretkeyisobviouslyreplacedxD
      ADMIN_EMAIL: [email protected]
      ADMIN_PASSWORD: mypasswordisreplaced

matsicking avatar May 12 '25 10:05 matsicking

Have you tried http://sub.domain.tld?

urania-dev avatar May 12 '25 10:05 urania-dev

Yup, same error :(

matsicking avatar May 12 '25 10:05 matsicking

This is weird,

Would you check with the same origin and public URL, and rebuilding the container?

urania-dev avatar May 12 '25 11:05 urania-dev

Are you behind a firewall or proxy? Have you test it like http://machine:port ?

urania-dev avatar May 12 '25 11:05 urania-dev

@skyhoppertv Have you tried just sub.domain.tld without the slash at the end maybe?

PinguDEV-original avatar May 13 '25 09:05 PinguDEV-original

As u can see in the compose.yml there is no slash there ;)

matsicking avatar May 13 '25 10:05 matsicking

Are you behind a firewall or proxy? Have you test it like http://machine:port ?

Updates on this?

urania-dev avatar May 13 '25 15:05 urania-dev

Are you behind a firewall or proxy? Have you test it like http://machine:port ?

Yup, the server connects via VPN to a VPS and there is a reverse proxy

snapp_1  | Listening on 0.0.0.0:3000
snapp_1  | 611 |         return event.fetch(info, init2);
snapp_1  | 612 |       },
snapp_1  | 613 |       /** @param {string[]} deps */
snapp_1  | 614 |       depends: (...deps) => {
snapp_1  | 615 |         for (const dep of deps) {
snapp_1  | 616 |           const { href } = new URL(dep, event.url);
snapp_1  |                                  ^
snapp_1  | TypeError: "i18n" cannot be parsed as a URL.
snapp_1  |  code: "ERR_INVALID_URL"
snapp_1  |
snapp_1  |       at depends (/app/build/server/index.js:616:28)
snapp_1  |       at <anonymous> (/app/build/server/entries/pages/_layout.server.ts.js:4:3)
snapp_1  |       at load (/app/build/server/entries/pages/_layout.server.ts.js:3:14)
snapp_1  |       at run (node:async_hooks:64:22)
snapp_1  |       at with_event (/app/build/server/index.js:67:22)
snapp_1  |       at <anonymous> (/app/build/server/index.js:604:24)
snapp_1  |       at load_server_data (/app/build/server/index.js:571:32)
snapp_1  |       at <anonymous> (/app/build/server/index.js:1959:35)

matsicking avatar May 14 '25 06:05 matsicking

But now it's not "Uh oh!!" on the web page, but giving Internal Error 500

matsicking avatar May 14 '25 06:05 matsicking

That typerror about i18n is confusing...

urania-dev avatar May 14 '25 10:05 urania-dev

trying to upload 0.9-rc-019 that should address this issues on first load and homepage

urania-dev avatar Jun 01 '25 17:06 urania-dev

thx! Will try this, when its uploaded!

matsicking avatar Jun 02 '25 07:06 matsicking

Still this error:

snapp_1  | 677 | };
snapp_1  | 678 | var ssr = function(request) {
snapp_1  | 679 |   if (origin) {
snapp_1  | 680 |     const requestOrigin = get_origin(request.headers);
snapp_1  | 681 |     if (origin !== requestOrigin) {
snapp_1  | 682 |       request = new Request(origin + url, {
snapp_1  |                       ^
snapp_1  | TypeError: Failed to construct 'Request': Invalid URL "domain.dev/"
snapp_1  |  code: "ERR_INVALID_URL"
snapp_1  |
snapp_1  |       at ssr (/app/build/handler.js:682:17)

With 0.9-rc-019

matsicking avatar Jun 02 '25 08:06 matsicking

And it's still "Uh oh!!" on the main page

matsicking avatar Jun 02 '25 08:06 matsicking

sorry i meant, the app is reachable if you use http://machine:port?

i don't understand where the error lies, as it is sveltekit that handle that stuff, not me.

edit: from what i see the origin misses the protocol causing the error, also you set origin in docker compose (with or without protocol) but the proxy how interact with it?

urania-dev avatar Jun 02 '25 08:06 urania-dev

I got it to work! Thanks for the help!

matsicking avatar Jun 03 '25 11:06 matsicking

Wonderful, what was the error? Or has been enough to set the vars? :)

urania-dev avatar Jun 03 '25 11:06 urania-dev

with the new version and the right vars it's working

matsicking avatar Jun 03 '25 12:06 matsicking

i have the same problem, i need help with this pls

What is the setting that i need to edit,? have a Reverse Proxy with HAProxy and i have the same error

The proxy make the connection with the IP http://X.X.X.X:3030 (i change the external docker port) and latter i use the https://sub.domain.tld to connect

If i put the IP in the origin i got this error:

@zenstackhq/server: ZenStackHandler installing routes at prefix: /api
Listening on 0.0.0.0:3000
677 | };
678 | var ssr = function(request) {
679 |   if (origin) {
680 |     const requestOrigin = get_origin(request.headers);
682 |       request = new Request(origin + url, {
681 |     if (origin !== requestOrigin) {
TypeError: Failed to construct 'Request': Invalid URL "X.X.X.X:3030/"
                      ^
 code: "ERR_INVALID_URL"
      at ssr (/app/build/handler.js:682:17)
services:
  snapp:
    image: uraniadev/snapp:latest
    hostname: acortador-snapp
    ports:
      - 3030:3000
    environment:
      ORIGIN: X.X.X.X:3030
      PUBLIC_URL: https://sub.domain.tld
      DATABASE_PROVIDER: sqlite
      DATABASE_URL: file:./db.sqlite

My first Try was with this settings:

@zenstackhq/server: ZenStackHandler installing routes at prefix: /api
Listening on 0.0.0.0:3000
677 | };
678 | var ssr = function(request) {
679 |   if (origin) {
680 |     const requestOrigin = get_origin(request.headers);
682 |       request = new Request(origin + url, {
681 |     if (origin !== requestOrigin) {
TypeError: Failed to construct 'Request': Invalid URL "**sub.domain.tld**/"
                      ^
 code: "ERR_INVALID_URL"
      at ssr (/app/build/handler.js:682:17)
services:
  snapp:
    image: uraniadev/snapp:latest
    hostname: acortador-snapp
    ports:
      - 3030:3000
    environment:
      ORIGIN: **sub.domain.tld**
      PUBLIC_URL: https://sub.domain.tld
      DATABASE_PROVIDER: sqlite
      DATABASE_URL: file:./db.sqlite

Crosus97 avatar Jul 18 '25 13:07 Crosus97

try both PUBLIC_URL: https://sub.domain.tld ORIGIN: https://sub.domain.tld

urania-dev avatar Jul 18 '25 13:07 urania-dev