Home Redirection on post form submission with AMP
Reply: 0

Redirection on post form submission with AMP

user1077
1#
user1077 Published in May 23, 2018, 8:09 pm

I am converting my blog application into Google AMP, I am stuck in one part that is blog submission.

The post form in amp supports only XHR, The blogs are successfully coming to create action and getting created.

Now i dont know how to redirect it to show page.

The things i tried

def create
  @blog = Blog.create(blog_params)
  respond_to do |format|
    response.headers["AMP-Redirect-To"] = "#{params["__amp_source_origin"]}/blogs"
    response.headers["AMP-Access-Control-Allow-Source-Origin"] = params["__amp_source_origin"]
    response.headers["Access-Control-Expose-Headers"] = "#{response.headers["AMP-Redirect-To"]},#{response.headers["AMP-Access-Control-Allow-Source-Origin"]}"
    format.json { head :ok } 
  end
end

where as **params["__amp_source_origin"]** is the domain of site, it comes when i submit the form.

I have used ngrok as it works only with https://

Your suggestion will be great helpful, sitting from a day.

Thank you

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30828 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO