typicode / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Other
73.11k stars 7.03k forks source link

How to make it over https #947

Open Szmycu opened 5 years ago

Szmycu commented 5 years ago

how to configure https://github.com/typicode/hotel this or something else to work over https.

In my case I use global ip 35.195.249.40 (no localhost)

i want to use https://35.195.249.40

I tried ngrok and it worked but with free plan it assigns always random subdomains.

i made like here described https://github.com/typicode/hotel/issues/321#issuecomment-467006340

made video how it looks https://streamable.com/fghsn

please help me how to make it https

Szmycu commented 5 years ago

okkkkkkkkk.

I made this finally with nginx and reverse proxy

mjcguada commented 5 years ago

Hi @Szmycu how did you configure nginx? I have a public url and a relative url but I don't know how to configure it neither json-server

Szmycu commented 5 years ago

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04#step-5-setting-up-server-blocks-(recommended) https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04 https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04

follow all steps in these tutorials. it took my whole day or more to make all things working xd

czw., 18 kwi 2019 o 16:44 mjcguada notifications@github.com napisał(a):

Hi @Szmycu https://github.com/Szmycu how did you configure nginx? I have a public url and a relative url but I don't know how to configure it neither json-server

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/typicode/json-server/issues/947#issuecomment-484539789, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSFCK33Z7Y73LJ67GFF243PRCCMFANCNFSM4HEHJSDA .

mjcguada commented 5 years ago

Wow, thank you! I've read this tutorials but I have a problem:+ I am doing POST from a app in Unity, with a "Content-type" header (application/json), and json-server is doing POST, and GET properly image But inside base.json there is only ids, not info inside them image Can you think of something please?

PS: this is my mime.types: image My .conf of sites-available/enabled image

and finally my nginx.conf image image

And this is the POST code: https://pastebin.com/zt7BPUFz

Thank you so much!

Szmycu commented 5 years ago

i think probably ur json is not structured properly, is the data in json format? how you send post requests? try with some program: insomnia, postman or something like that. try search for functions to json encode your data

niedz., 21 kwi 2019 o 18:51 mjcguada notifications@github.com napisał(a):

Wow, thank you! I've read this tutorials but I have a problem:+ I am doing POST from a app in Unity, with a "Content-type" header (application/json), and json-server is doing POST, and GET properly [image: image] https://user-images.githubusercontent.com/22896054/56472928-059a8d00-6465-11e9-98f2-614735cffbbe.png But inside base.json there is only ids, not info inside them [image: image] https://user-images.githubusercontent.com/22896054/56472940-206d0180-6465-11e9-88bd-b42883e71cf5.png Can you think of something please?

PS: this is my mime.types: [image: image] https://user-images.githubusercontent.com/22896054/56472963-4f837300-6465-11e9-915c-1494e63167b7.png My .conf of sites-available/enabled [image: image] https://user-images.githubusercontent.com/22896054/56472976-72158c00-6465-11e9-8ddc-3f10fd52a15c.png

and finally my nginx.conf [image: image] https://user-images.githubusercontent.com/22896054/56472995-b43ecd80-6465-11e9-830c-8e3f3d26690b.png [image: image] https://user-images.githubusercontent.com/22896054/56472999-c28ce980-6465-11e9-9a20-7b895ede5a43.png

And this is the POST code: https://pastebin.com/zt7BPUFz

Thank you so much!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/typicode/json-server/issues/947#issuecomment-485266153, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSFCK6DXMRSUAPB5X3I473PRSLRXANCNFSM4HEHJSDA .

mjcguada commented 5 years ago

I'm using unitywebrequest https://pastebin.com/zt7BPUFz thanks man :D I'll try insomnia too

Szmycu commented 5 years ago

try something like here https://stackoverflow.com/posts/45476691/revisions to send data as json format. becouse now you send ur data in dataform format. im think this is issue here

niedz., 21 kwi 2019 o 23:18 mjcguada notifications@github.com napisał(a):

I'm using unitywebrequest https://pastebin.com/zt7BPUFz thanks man :D I'll try insomnia too

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/typicode/json-server/issues/947#issuecomment-485283013, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSFCK3CZVJN2FRZBQJPJJTPRTK27ANCNFSM4HEHJSDA .

ngduc commented 5 years ago

I'm too lazy to check out hotel (pun intended :) so I stayed and whipped up a quick-and-dirty command line: (it can takes a .json or .js file)

$ json-now -k keyFile -c certFile -p 3003 data.json

https://github.com/ngduc/json-now