Sinatra App Not Previewing (but it works!)

Hi,

I’m a total newbie at Ruby and Sinatra and I followed these example

to create this app
billowy-rogue-duke ← I can’t link cos only 2 links allowed and the tracking of links has gone wrong ffs

The thing is, I think it works, see here:

And my problem is that it doesn’t Preview in the pane but appears to work OK, oh scrub that… now the app doesn’t work. I’ve tried editing the glitch.json file to have a start script of ruby app.rb and bundle exec rackup config.ru -p $PORT -s thin -o 0.0.0.0" and many other things and I’m not sure which may be best…

I’ve tried all sorts and after remixing the project , here, it works fine, so was the problem that something grabbed the port and messed it all up?

project tricolor-wobbly-lady <-works but this won’t let me add more than 2 links.

Any clues gratefully received, or a better Sinatra starter project on Glitch would be useful.

Tom

1 Like

Note that Glitch has no official support or runners for Ruby. That said, as long as you use the correct run instructions in your glitch.json “start” section to run your server, using $PORT as the server port, things should start up. If you don’t see things working, remember to look at the logs (all the way at the bottom-left of the editor) to see if there are any errors/warnings/etc that you’ve missed.

n

referring to this problem?

this is from security options colloquially known as x-frame-options, wherein the server (I’m guessing sinatra itself here) tells the browser not to show this page embedded in another website (the Glitch editor at glitch.com here).

searching for sinatra and x-frame-options together should probably have some advice on configuring that

the port stuff looks fine, as there’s an HTTP response bearing this security header at all

Note that if it is is x-frame restrictions, you should be able to view the preview (which isn’t technically a preview, it’s literally just your glitch.me domain) by picking “preview in a new window”, which just loads your project domain in a new tab/window.

https://billowy-rogue-duke.glitch.me/
loads ok here

Ahhaha… Thank you @wh0 and @Pomax

I guessed it was something along the lines you suggest… And I appreciate that Ruby isn’t supported and although I haven’t sorted it yet, I reckon if I can figure how to set x-frame restrictions then it’ll be fine.

THANKS LOADS!

Tom

1 Like

Yep. That did it. Here it is.

I found (as ever) a dozen different way to do this on substack, but adding this line to the top of every route worked. Like this, for any fellow newbies finding this.

get ‘/’ do
headers({ ‘X-Frame-Options’ => ‘’ })
erb :tasks, layout: :index
end

Thanks again!

2 Likes