Help deploy a node.js server on railway

I want to deploy some node code with railway
51 Replies
Percy
Percy2y ago
Project ID: N/A
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
i started with template but its strange its using .mjs
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
my code is like this can I deploy this or i need to make changes
Brody
Brody2y ago
yes the project is in the format of a node module
nikivi
nikiviOP2y ago
not sure what you mean I wonder if I can just run railway link and it will deploy
Brody
Brody2y ago
this might be more what you want https://github.com/brody192/express-simple that isn't quite how it works you will want to fork that repo, clone it to your computer, make the changes you want, push the changes to github, then add a new service from that repo you forked
nikivi
nikiviOP2y ago
thanks will try now
Brody
Brody2y ago
cool!
nikivi
nikiviOP2y ago
hey @Brody i am trying to deploy this project with railway now
Brody
Brody2y ago
any problems?
nikivi
nikiviOP2y ago
testing it out on stripe side actually was magical
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
i did it via ui
Brody
Brody2y ago
oh so no issues?
nikivi
nikiviOP2y ago
im trying to change stuff on stripe side to point to prod url @Brody can i get logs in railway oh ok i see it
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
mm doesn't seem to work
Brody
Brody2y ago
you changed the template well duh lol i mean you changed the part of it that allowed it to work effortlessly on railway
nikivi
nikiviOP2y ago
GitHub
express-simple/index.js at main · brody192/express-simple
Contribute to brody192/express-simple development by creating an account on GitHub.
nikivi
nikiviOP2y ago
im looking at yours now
Brody
Brody2y ago
please read this docs page to get you back on track https://docs.railway.app/troubleshoot/fixing-common-errors
nikivi
nikiviOP2y ago
const port = process.env.PORT || 3000

app.listen(port, () => console.log(`Running on port ${port}`))
const port = process.env.PORT || 3000

app.listen(port, () => console.log(`Running on port ${port}`))
ok so i added this its still failing unless i miss something else
Brody
Brody2y ago
failing how?
nikivi
nikiviOP2y ago
the thing though well web hooks don't get sent to that url maybe its a stripe issue
Brody
Brody2y ago
send me the railway domain for that service?
nikivi
nikiviOP2y ago
stripe-payment-hooks-production.up.railway.app
nikivi
nikiviOP2y ago
btw feature request is so copy gives full url
nikivi
nikiviOP2y ago
with https:// not sure why it only gives raw thing
Brody
Brody2y ago
yep, the app works fine
nikivi
nikiviOP2y ago
ok then will ask on stripe side
Brody
Brody2y ago
stripe will have some type of logs for why it fails, send them over and im sure they have a test the webhook endpoint button or something right?
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
before deploying i was working with it locally and it worked stripe listen --forward-to localhost:4242/webhook i ran this
Brody
Brody2y ago
what endpoint do you have registered to handle the stripe webhooks
nikivi
nikiviOP2y ago
Brody
Brody2y ago
in code
nikivi
nikiviOP2y ago
im not sure i get you
nikivi
nikiviOP2y ago
GitHub
stripe-payment-hooks/index.js at main · nikitavoloboev/stripe-payme...
Contribute to nikitavoloboev/stripe-payment-hooks development by creating an account on GitHub.
nikivi
nikiviOP2y ago
is my code for stripe web hooks
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
i get a checkout page like this
const normalMonthly = await stripe.checkout.sessions.create({
success_url: process.env.STRIPE_SUCCESS_URL!,
mode: "subscription",
metadata: {
userDetailsId: userDetailsId,
},
line_items: [
{
quantity: 1,
price: process.env.STRIPE_NORMAL_MONTH_SUBSCRIPTION!,
},
],
})
const normalMonthly = await stripe.checkout.sessions.create({
success_url: process.env.STRIPE_SUCCESS_URL!,
mode: "subscription",
metadata: {
userDetailsId: userDetailsId,
},
line_items: [
{
quantity: 1,
price: process.env.STRIPE_NORMAL_MONTH_SUBSCRIPTION!,
},
],
})
created like so then when users complete the checkout web hooks should get sent to this railway endpoint
Brody
Brody2y ago
your endpoint is /webhook you need to tell stripe to call that endpoint
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
ok trying with this
Brody
Brody2y ago
you are missing the /webhook endpoint here
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
thank you that worked
Brody
Brody2y ago
awsome for node apps that you have full control over the codebase, its best to define the start command/script in the package.json file, but i see you dont have one
Want results from more Discord servers?
Add your server