VITE App gets html instead of json

ammertech
HOBBY

4 months ago

Hey,

i wanted to update my app that was running for a while here and I did a lot of changes to it, but it is running anywhere but not on railway (anymore).
I dont know what changed, but it seems my backend returns a html instead of a json on api query. (maybe some kind of html error). But that does not make sense, configuration looks solid and it runs elsewhere and local as well. Checked on the old version of my app that was running here flawless, turns out, it has the same issue now w/o touching code base.
main-KZEDdE0t.js:57 Error in createOrGetUser: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

createOrGetUser @ main-KZEDdE0t.js:57

await in createOrGetUser

(anonymous) @ main-KZEDdE0t.js:57

(anonymous) @ main-KZEDdE0t.js:57

R2 @ main-KZEDdE0t.js:40

w0 @ main-KZEDdE0t.js:40

(anonymous) @ main-KZEDdE0t.js:40

w @ main-KZEDdE0t.js:25

O @ main-KZEDdE0t.js:25

main-KZEDdE0t.js:57 Failed to init user: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

Any help would be appreciated.

thank you

Solved

3 Replies

chandrika
EMPLOYEE

4 months ago

Hey there, are you still seeing the errors (I wasn't able to see them in your deploy logs so perhaps this is fixed? If so, please do share what fixed it if you can with the community!


Status changed to Awaiting User Response railway[bot] 4 months ago


ammertech
HOBBY

4 months ago

Hey,

sorry for the confusion.
Deployment and stuff looks "fine". But When I access my app, I see in my browser dev tools that page returns an html instead of json when calling the api. That only happens on railway.

(and sometimes also 405).
main-Bo0BSsig.js:57 Error in createOrGetUser: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

createOrGetUser@main-Bo0BSsig.js:57await in createOrGetUserm@main-Bo0BSsig.js:57await in mon@main-Bo0BSsig.js:37Ca@main-Bo0BSsig.js:37On@main-Bo0BSsig.js:37sg@main-Bo0BSsig.js:37og@main-Bo0BSsig.js:37(anonym)@main-Bo0BSsig.js:37bT@main-Bo0BSsig.js:40Br@main-Bo0BSsig.js:37cg@main-Bo0BSsig.js:37vd@main-Bo0BSsig.js:37Oh@main-Bo0BSsig.js:37

main-Bo0BSsig.js:57 Failed to init user: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON

(anonym)@main-Bo0BSsig.js:57

What is even more weird is, that the old simple version of the app was running here as well and I did not do changes to it, now it is broken with the same error (unfortunately i dont know since when). But maybe you did some changes in the backend?


Status changed to Awaiting Railway Response railway[bot] 4 months ago


ammertech
HOBBY

3 months ago

I entered "npm run start" as a custom start command. That somehow fixed the problem.


Status changed to Solved ammertech 3 months ago


VITE App gets html instead of json - Railway Help Station