algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
177 stars 45 forks source link

Algolia links posts to a 0.0.7.227 url #85

Closed uicscribe closed 4 years ago

uicscribe commented 4 years ago

I have two identical sites. One is for testing purposes and the other is for production.

Both sites are successfully deployed via netlify and algolia is successfully indexed. All search bar functions work fine. However for the production site, when the actually posts themselves are clicked, algolia changes the root to a strange 0.0.7.227 url. This does not happen for the testing site. Both sites are identical in code except the algolia env variables.

The production site and its github

The testing site with no problems and its github

Why does this problem appear on one but not the other when they are both essentially the same?

I am generating my search results URL fromsrc/pages/search.js

import React from "react"
import { Link } from "gatsby"
import Layout from "../components/layout"
import PageBreadcrumb from "../components/pageBreadcrumbs"
import SEO from "../components/seo"
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';

const searchClient = algoliasearch('L939SA528T', '6bf2bcd990937092c431629e2b44740d');
const Hit = ({ hit }) =>
<article>
    <Link to={`/${hit.fields.slug}`}>
        <h1>{hit.title}</h1>
        <h2>{hit.date}{" "}by{" "}<span>{hit.author}</span>{" "}</h2>
        <p>{hit.excerpt}</p>
    </Link>
</article> 

export default class extends React.Component {

    render() {
        return (
            <Layout>
                <PageBreadcrumb crumbs={ [ 'Home', 'Search' ] } />
                <div className="searchbarContainer">
                <SEO title="Search - Yonsei UIC Scribe | Underwood International College"></SEO>
                    <InstantSearch className="searchbar" searchClient={searchClient} indexName="Articles">
                        <SearchBox />
                        <Hits hitComponent={Hit} />
                    </InstantSearch>
                </div>
            </Layout>
        )
    }
}
uicscribe commented 4 years ago

Removing the /from <Link to={/${hit.fields.slug}}> solved the problem