deploy React + VITE and Express
I have my React application with VITE and an express server to send emails, when I want to deploy it raises the server but I can't get it to read the static files from /dist
51 Replies
3161844c-1cfc-470c-995a-24c2de301990
can you please share your repo?
GitHub
GitHub - Papotta/portfolio
Contribute to Papotta/portfolio development by creating an account on GitHub.
currently you have a backend and a frontend mushed together into a single directory, please separate them out into a
/frontend
and a /backend
folder within this repoI doit but now i have this problem
don't worry it it deploying successful yet, we aren't at that stage yet
https://github.com/brody192/vite-react-template
copy the nixpacks.toml and Caddyfile from this repo into your frontend folder
and while you're at it, you can delete your "nixpack.toml" file, it's both spelt wrong and uses completely wrong syntax
like this?
you spelt it wrong, please be careful with the spelling and the casing, it matters
alredy corrected the Canddyfile
Caddyfile*
show me a screenshot of your railway project please
its the same error than before, I have to install something?
nope, I said not to worry about it failing yet
go into it's settings and set the root directory to
/frontend
ready
now we can worry about it failing
so it should have redeployed after you made that change, let me know how the build goes
it dont failt but I have this now
how long ago did you add the domain to the service?
5 minuts
oh wait
then the new domain hasn't propagated through the router yet, should work any minute now
now I can see the static page
awesome
the only left is run the erver in the backend folder, its not running
of course not, we need another railway service for that
so go ahead and do that
new railway service, and set the root directory to /backend
So I upload the project from github again?
yes
and change the root directory to /backend?
yep
ok I'll try it
the server run good, but I can do request to them, the fetch send error 405 Mehod Not allowed, but iI verify and the cors its correct
make sure you use http and specify the correct method when making the request
In development it works without any problem, but in production the same error continues
show me your fetch calls please
ok give me a sec
this one is in development
and this ins production
can you test your mail endpoint on railway locally from postman or a similar api testing app
ok i will try
I have to add a domain for the server?
oh you are trying to call the wrong domain lol
you need to add a domain to that backend service and then call that domain
I supoused jja let me try
try every way but I can delete the original domain of the frontend, I have set the variables environ correctly
and try this too but still calling the frontend domain
then you need to find out where you have your frontend domain hardcoded
could be something of Caddyfile?
nope
thank you very much for your help in all this time
where you able to get the frontend to call the correct domain?
I dont found nothing wrong, so I change browser and works, it was cache