I’m trying to develop a jets app in the cloud9 IDE.
When running locally the links point to domain.com**/dev**/fu instead of domain.com/fu and generate a 404 error.
E.g.:
https://[…].vfs.cloud9.us-east-1.amazonaws.com/dev/locations/new
instead of the working:
https://[…].vfs.cloud9.us-east-1.amazonaws.com/locations/new
How do I either remove the “/dev” or change the path to become valid?
Just tested it and it worked. Looks like this was released in v1.8.6. https://github.com/tongueroo/jets/issues/201 Hoping that all you need to do is upgrade your version of Jets.
Odd Thought maybe it was related to the region you were running in: us-east-1. But created a cloud9 machine in us-east-1 and tested and it worked fine for me. So it’s not region related.
Wondering what value your cloud9 environment has for the HTTP_HOST env variable. The env is from the rack request. HTTP_HOST should be a pattern that matches the /cloud9\..*\.amazonaws\.com/ regexp.
Maybe add puts ENV["HTTP_HOST"] to one of your conrtrollers. Example:
class PostsController < ApplicationController
def index
puts ENV["HTTP_HOST"]
puts ENV['HTTP_X_AMZN_TRACE_ID']
end
end
Same issue with a fresh environment and the variables are empty as well.
The only non default option I choose was Ubuntu instead of Amazon Linux.
Trying a fresh env with Amazon to see if that fixes it.
So sorry. Didn’t test it before asking the question. The env that we want to see is by the time it gets to the on_aws? call. Let’s try again:
Modification to the code
Run this to show where the jets source is on your machine, you should see something like this:
$ bundle show jets
/home/ec2-user/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.13
From there go to:
lib/jets/controller/middleware/local.rb
Modify the on_aws?(env) with some puts debugging:
def on_aws?(env)
puts "on_aws? HTTP_HOST #{env['HTTP_HOST'].inspect}"
puts "on_aws? HTTP_X_AMZN_TRACE_ID #{env['HTTP_X_AMZN_TRACE_ID'].inspect}"
return false if ENV['TEST'] # usually with test we're passing in full API Gateway fixtures with the HTTP_X_AMZN_TRACE_ID
on_cloud9 = !!(env['HTTP_HOST'] =~ /cloud9\..*\.amazonaws\.com/)
!!env['HTTP_X_AMZN_TRACE_ID'] && !on_cloud9
end
Start a server and load the endpoint in a browser
jets server --host 0.0.0.0 --port 8080
You should use the url it spits out and load it in the browser now.