Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Your guide to easily deploy a standalone version is here :) #176

Open
ryanckulp opened this issue Dec 31, 2022 · 8 comments
Open

Your guide to easily deploy a standalone version is here :) #176

ryanckulp opened this issue Dec 31, 2022 · 8 comments

Comments

@ryanckulp
Copy link

ryanckulp commented Dec 31, 2022

update - i've just forked a deployable version to reduce some of the steps below.

hi folks,

i noticed a bunch of you (#140, #172, #135, #120, #119, #88) are struggling to get this working on your own server. below is a free and easy solution!

first, i suggest you get it running locally via the included README instructions:

# 1. install dependencies
npm install # for reference, i used node 16.17.0

# 2. config your email inside lib/config.js (using Gmail as an example)
- host: 'smtp.gmail.com'
- auth: {  user:  'youraddress@gmail.com' }
- auth: { pass: make app-specific Gmail password: https://security.google.com/settings/security/apppasswords

# 3. run the server 
redis-server # should default to port 6379
node server/app.js # in a new terminal tab! keep redis running separately

# 4. try sending a text message
curl -X POST http://localhost:9090/text \
   -d number=<your-cell-phone> \
   -d "message=I sent this message for free with Textbelt"

when this works, you're ready to deploy. push this code up to a new PRIVATE GitHub repository (since we added SMTP credentials), or change those hard-coded values to environment variables.

git add .
git commit -m 'prepare textbelt for deploy'
git remote set-url origin https://github.com/yourusername/your_new_repo

deploying a self-hosted version of Textbelt

  1. create a free account at https://render.com. this is basically like Heroku. i've never used it until today, not a promo.
  2. click to make a "Web Service" from your dashboard or click New > Web Service from navigation
  3. auth your GitHub and select the textbelt repository you created
  4. name your app, e.g. textbelt, then set Environment to Node, Build Command to npm install, and Start Command to node server/app.js
  5. select the free Instance Type
  6. if you refactored lib/config.js to use environment variables, plug those in by clicking Advanced > Add Environment Variable
  7. click Create Web Service at the very bottom

this will build and deploy your code. when it's done, click the URL generated by Render and you should see the "homepage" saying I'm online!.

now for the final task. if you try creating a text message via our previous strategy:

curl -X POST https://your-textbelt-server.onrender.com/text \
  -d number=<your-cell-phone> \
  -d "message=A free text message with Textbelt on Render"

you'll likely get a CANNOT Post response with some HTML markup. i couldn't figure out why Render blocks the request as the server already has CORS enabled.

to fix this, simply modify your code inside server/app.js:

// before
app.post('/text', (req, res) => {

// after
app.get('/text', (req, res) => {

Render won't complain about cross origin GET requests. inside your Render project dashboard click "Manual Deploy" to update your server with the /text endpoint HTTP method update.

you'll be up and running in seconds! enjoy.

@globemediaofficial
Copy link

Awesome! I love that this solution doesn't have to be hosted on a host computer since it uses render.com.

@aryangupta24
Copy link

I am getting a error - Invalid phone number

curl -X POST http://textbelt-05ea.onrender.com/text
-d number='+14052955384'
-d "message=I sent this message for free with Textbelt"

@brian404
Copy link

what name shuld i use for envioment varibale lib/config.js

@ryanckulp
Copy link
Author

what name shuld i use for envioment varibale lib/config.js

i'm not sure what you are referring to. here is the lib/config.js source. which variable, which line of code?

https://github.com/founderhacker/textbelt_deployable/blob/master/lib/config.js

@brian404
Copy link

brian404 commented Jan 12, 2024 via email

@ryanckulp
Copy link
Author

i suggest trying another number first. perhaps the one you tested is already blacklisted.

@brian404
Copy link

I am getting a error - Invalid phone number

curl -X POST http://textbelt-05ea.onrender.com/text -d number='+14052955384' -d "message=I sent this message for free with Textbelt"

same error man

@brian404
Copy link

brian404 commented Jan 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants